Ruby on Rails and Rake problems: uninitialized constant Rake::DSL

I’m having a really frustrating issue: Rake is being dumb. Here’s how the problem comes about: $ rails new test_app $ rails generate scaffold new_scaffold field1:string field2:text Both of those work just fine, but then when I do this, $ rake db:migrate I get the following error. (in /home/mikhail/test_app) rake aborted! uninitialized constant Rake::DSL /usr/lib/ruby/1.9.1/rake.rb:2482:in … Read more

How to pass arguments into a Rake task with environment in Rails? [duplicate]

This question already has answers here: How to pass command line arguments to a rake task (20 answers) Closed 4 years ago. I am able to pass in arguments as follows: desc “Testing args” task: :hello, :user, :message do |t, args| args.with_defaults(:message => “Thanks for logging on”) puts “Hello #{args[:user]}. #{:message}” end I am also … Read more

Do rails rake tasks provide access to ActiveRecord models?

I am trying to create a custom rake task, but it seems I dont have access to my models. I thought this was something implicitly included with rails task. I have the following code in lib/tasks/test.rake: namespace :test do task :new_task do puts Parent.all.inspect end end And here is what my parent model looks like: … Read more

Difference between rake db:migrate db:reset and db:schema:load

The difference between rake db:migrate and rake db:reset is pretty clear to me. The thing which I don’t understand is how rake db:schema:load is different from the former two. Just to be sure that I am on the same page: rake db:migrate – Runs the migrations which haven’t been run yet. rake db:reset – Clears … Read more