Ruby on Rails Monday, October 28, 2013

I ran into a "chicken before the egg" problem where a gem was expecting the tables to be present when loaded which was fine until you try and build the db from scratch using db:setup. When it hits db:schema:load the environment loads and the gem errors out as the tables aren't present. I made a custom task that connected to ActiveRecord and then loads the schema file. Using essentially the same methods as db:create uses to create the db and schema:load uses to load the schema. This seems to work without problems.

Is there a reason the environment is normally loaded for this task? Just wondering If I'm missing something that'll kick me in the ass later.

I read and followed some issues about it: https://github.com/rails/rails/issues/4772
but they don't say why they decided to load or not load the env at the time.

Cheers,
Brian

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/448ba9ad-1d05-4799-9ff7-4c76ad54d311%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment