RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: olivierlacan
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.
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.
# Provide a default URL as a default if there hasn't been a file uploaded:
"/images/fallback/" + [version_name, "default.png"].compact.join('_')