RailsCasts Pro episodes are now free!

Learn more or hide this

Olivier Lacan's Profile

GitHub User: olivierlacan

Site: olivierlacan.com

Comments by Olivier Lacan

Avatar

Important note. Database extensions and index creation (at least for Postgres ones like those used in this episode) are supported since Rails 4 so there should be no need to switch to structure.sql as advised in this episode anymore.

See this Pull Request merged over a year ago.

Avatar

Don't use model.image.to_s but instead model.image.url

Using to_s breaks the default_url override if you want to use a default image when none exists.

This guy:

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