RailsCasts Pro episodes are now free!

Learn more or hide this

Jeremy Becker's Profile

GitHub User: iamjbecker

Site: iamhim.co

Comments by Jeremy Becker

Avatar

Use model.image.url

Using to_s breaks the default_url.

This guy: (in the Uploader) is where you set the default image.

ruby
  # Provide a default URL as a default if there hasn't been a file uploaded:
  def default_url
    "/images/fallback/" + [version_name, "default.png"].compact.join('_')
  end
Avatar

Note to all using FriendlyId for pretty URLs. In any view to create an new image be sure to change <%= link_to "New Image", new_image_path(:x_id => @x) %> to <%= link_to "New Image", new_image_path(:x_id => @x.id) %> or else you spend countless hours trying to figure out why it just won't work.

Thanks, Ryan! This was great!