I created a new engine in Rails 3.1.3 and apparently there's that rake task that copies over all migrations. I tried following rake abc:install:migrations which threw:
rake aborted!
Don't know how to build task 'abc:install:migrations'
(See full trace by running task with --trace)
I also tried rake abc_engine:install:migrations with the same result.
Then I read bundle exec rake railties:install:migrations or bundle exec rake railties:install:migrations FROM=abc_engine should do the trick too but no success. Nothing was copied even though no error was thrown.
My migrations are located in db/migrate/ within the engine folder and I ran all commands above from spec/dummy/
Does anyone know how to use this new rake task in order to copy migrations from the engine?
I ran this instead:
rake railties:install:migrations
And my migrations were copied from the engine.
Hope this helps.
I finally got found/got lucky with my (similar) issue. For the first error, it just disappeared, not sure why. Then I figured out that I didn't created the migrations using the usual file name format, so the ActiveRecord::Migrator.migrations method was ignoring them.
If the app you're mounting the engine to doesn't already have ActiveRecord (i.e. you're introducing ActiveRecord to your host app for the first time by mounting the engine), you can get this error as well. Specifically, you'll get this error if you don't have require "active_record/railtie" in your application.rb, or if it's commented out. That line is what enables the rake railties:install:migrations task, which is defined here. rake railties:install:migrations is, in turn, called by the rake abc_engine:install:migrations task here.
Tl;dr: try adding require "active_record/railtie" to your application.rb if it's not already there.
Related
Here is a very strange issue I have on my new computer setup (otherwise, it's working on my other setups).
I'm running : rake db:migrate
No errors, but it does nothing...
rake db:migrate:status show me the list of pendings migrations (marked as "down"), the ones that I effectively have in my bd/migrate folder.
Even if I run those commands or removing files in db/* manually, db:migrate is still useless.
rake db:drop:all
rake db:create
rake db:migrate
I have tried also db:reset, db:rollback STEP=1000.
If I specify a VERSION number (one from the list given by db:migrate:status) as:
rake db:migrate VERSION=20150106184930
I've got the following error:
No migration with version number 20150106184930
I have also generated a new migration with:
rails generate migration TestMigration
And again, db:migrate completely ignor it.
My current setup is: windows7, rails 4.2.0, rake 10.3.2.
Thanks for any help, clues...
After hours of deep debugging in rake, reinstalled all my complete setup, I finally figured out that the problem was comming from the "non so special" characters [ or ] somewere in my project path!!
DAMN RAILS!
Due to readability, all my project's folders start with "[NAME-OF-PROJECT]xxxx/"... then in this particular rails project comes a subfolder for the rails app.
No error, nothing that point you out that the path name could be the issue. I'm quite sur that "[" and "]" are not forbidden character (even on linux) : http://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words
And why "[" or "]" makes rake db:migrate failing and not rake db:migrate:status???
For me it clearly shows some weakness in rails architecture. I should probably do a bug report for that... can someone point me some report mailing list or whatever?
I hope that my misadventure will save hours for others.
If this is a new rails setup, you may not have gems on your system, but only in your app. Try prepending bundle exec to your rake commands.
bundle exec rake db:migrate
Try run gem update and try rake db:migrate again.
First time here, I hope do it right.
I'm following the railstutorial 3.2 and I'm in section 5.4, in the paragraph above to listing 5.32.
(In fact, you can just type rake by itself; the default behavior of rake is to
run the test suite.)
I used rake by itselft but I have a error since then. When I run:
"$ bundle exec rake spec" I get this error.
http://pastebin.com/F0wrEkT1
My database.yml is:
http://pastebin.com/tWAgeFTV
My problem is that I don't know why it is asking for production database when I didn't use it yet. And whe I look for the issue I don't find topics about (almost I didn't find it).
Do you have some clues to star looking or to know what is happening?
Thanks a lot.
I'm not sure why it is looking for the production DB but you may want to skip ahead. Just read a little further:
(In fact, you can just type rake by itself; the default behavior of rake is to run the test suite.) The only caveat is that using rake to run the tests for the current sample application will raise an error since it requires the test database to be prepared properly, a step we’ll defer to Section 6.2.1.
It recommends running:
bundle exec rake db:test:prepare
Hey people i know maybe 1% of ruby and need many help...
I migrated a system from one server to another server
When I try to insert an entry to the database using the system, I get the following error (remembering that I use ruby is 2.1):
undefined method `insert_record' for #<Array:0x007fec2a2b2fa0>
i know maybe this is a solution:
http://alok-anand-ror.blogspot.com.br/2013/11/undefined-method-insertrecord-for.html
i have gems of rake instaled 0.9.2 and 0.9.2.2
when i try run "rake db:migrate" (I think it would solve, I do not know) i received
rake aborted No rake file found
if somebody can help me I greatly appreciate.
thanks in advanced.
it seems your Rakefile is missing .
Check your rails folder should contain Rakefile with following content
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Demo::Application.load_tasks
~
and
undefined method `insert_record' for #<Array:0x007fec2a2b2fa0>
this error is because of incompatibility issues with rails and ruby , try upgrading rails
In rails 3.1 you can use the awesome rake task to copy in migrations as seen below from your engine.
rake my_engine:install:migrations
This normally works perfectly if i direct my Gemfile to the git repository or via :path.
However, if i just use the ruby gem directly
gem 'spud_admin'
my rake task disappears
Any ideas why this rake task disappears?
Well, I had a similar problem and managed to solve it thanks to jipiboily's comment. I have an engine called 'myEngine2' so I tried to call it like that:
rake myEngine2:install:migrations
but this failed. I than typed
bundle exec rake -T
there was a line:
rake my_engine2_engine:install:migrations # Copy migrations from
my_engine2_engine to application
I gave it a shot and it worked. Maybe it's the same problem in your case?
Issue was resolved. It had something to do with how jeweler had structured the gem environment. Switching to bundler and using rails plugin new seems to have resolved the issue.
When I run "bundle exec rake -T" in development, the assets:clear and assets:precompile tasks show up, but if I prefix that command with RAILS_ENV=production, or run it on a server where that variable is set, they don't. Has anyone run into this?
I'd removed rails/all from the application.rb and replaced it with the individual railties, excluding activerecord. Turns out you also need to require the sprockets railtie.