rubysherpas / r4ia

A place to file issues for Rails 4 in Action
2 stars 0 forks source link

Cannot precompile assets in production!! #10

Closed eriol12 closed 9 years ago

eriol12 commented 9 years ago

First thing you have to set carrierwave ENV! Using heroku config:add it sets the ENV variables but it will complain saying aws_access_key_id, aws_secret_access_key missing! So I had to resolve to figaro gem. Now here comes trouble. You follow the Heroku procedure and when you bundle exec rake assets:precompile RAILS_ENV=production it will abort with the following error (note this error will appear even if assets are precompiled during git push heroku -u master):

SQLite3::SQLException: no such table: states: SELECT "states".* FROM "states"
rake aborted!
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: states: SELECT "states".* FROM "states"
  (in /Users/coli/ticketee_review/app/assets/stylesheets/states.css.erb)
/Users/coli/ticketee_review/app/assets/stylesheets/states.css.erb:1:in `block in singleton class'
/Users/coli/ticketee_review/app/assets/stylesheets/states.css.erb:-5:in `instance_eval'
/Users/coli/ticketee_review/app/assets/stylesheets/states.css.erb:-5:in `singleton class'
/Users/coli/ticketee_review/app/assets/stylesheets/states.css.erb:-7:in `__tilt_70325732006880'
SQLite3::SQLException: no such table: states
/Users/coli/ticketee_review/app/assets/stylesheets/states.css.erb:1:in `block in singleton class'
/Users/coli/ticketee_review/app/assets/stylesheets/states.css.erb:-5:in `instance_eval'
/Users/coli/ticketee_review/app/assets/stylesheets/states.css.erb:-5:in `singleton class'
/Users/coli/ticketee_review/app/assets/stylesheets/states.css.erb:-7:in `__tilt_70325732006880'

Note this happens regardless even if you use postgresql in the database.yml!

radar commented 9 years ago

This problem has been fixed in Chapter 10. Rather than having the State.all call in the asset file, it's now done in-line in the application layout itself.