ruby on rails - Can't run rake db:schema:load unless the database is already loaded -


tricky. rails models include lines like:

scope :unread, where(arel_table[:read].eq(false)) 

this line can't run, however, unless arel_table[:read] defined, , it's undefined unless column exists. (this line rewritten not use arel, scopes cannot.)

however, when try run rake db:schema:load, nomethoderror resulting fact arel_table[:read] undefined. in short, it's catch-22. can't load database schema without running environment, , can't load environment unless database loaded.

is there better answer "comment out lines uncomment when done"? there's number of offending lines.

that's problem using arel on scope. may affect migration. simple solution go raw sql.

scope :unread, where('read = false') 

the longer answer class somehow loaded when running migration (it's not loaded). if can find causes loading of class during migration , work around it, can still use arel_table in scope. it's not worth it.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -