ruby on rails rake db:migrate aborted - ruby-on-rails

I am new on ruby on rails, I try to look for the answer to this type of problem. i have been looking for a long time and i haven't been able to find a solution.
I am working on windows vista home, ruby 2.0.0, rails 4.0.2.
I have try different ways to solve the problem and it seems that I do not understand what the output is telling me:
$ rake db:migrate
rake aborted!
LoadError: cannot load such file -- sqlite3/database
c:/Users/me/desktop/family_N/config/application.rb:7:in `<top (required)>'
c:/Users/me/desktop/family_N/Rakefile:4:in `<top (required)>'
Thank you for your fast reply.
I install devise and try rake db:create, and i got the same output.
Forgive my ignorance but, this is what I am looking at
db/migrate: 201405282050240_devise_create_user.rb.
db/schema.rb: ActiveRecord::schema.define(version: 20140617211300) do |t| ...
do this dates have to match?

Did you create your database? From the error posted, it would appear that you had not yet done so.
rake db:create
You do need to create the DB before you can migrate data to it.

try bundle exec rake db:create

Related

PG::ConnectionBad Error when trying to run rake db:migrate after creating model, using postgresql

Trying to get my rails up and running but am having a problem. When creating my new rails app on the command line I ran the usual
rails new PhotoApp -d postgresql
Generated my core scaffold. Then generated a model with attributes in the terminal and that was fine. After creating my model I first ran rake db:create and that returned a long log of characters with at the top telling me FATAL: role "PhotoApp" does not exist so then I tried rake db:migrate and that didn't work either returning me
rake aborted!
PG::ConnectionBad: FATAL: role "PhotoApp" does not exist
/Users/##$%^$#/Code/Projects/PhotoApp/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
WTF is going on here?
Thanks for any help.
The error is telling you that Postgres isn't finding your app. What does your database.yml file look like?
I would first run the rake task again, using the --trace as suggested:
rake db:create --trace
That will give you a more verbose tracing, so you can try to isolate the problem.
From experience I can tell you though that 'Roles' in Postgres can be a nightmare. How did you install Postgres on your machine? HomeBrew? The Postgres App?
Please post the full trace, as well as your database.yml file. This will help better assess the problem!

Rails: Could not find rake-10.1.1 in any of the sources

I am experiencing an error with running the Rake command. When I try to Rake in my Rails project, I get an error that says Could not find rake-10.1.1 in any of the sources.
I put Rake 10.1.1 in my Gemfile, but it appears to do nothing when I bundle install.
I've tried uninstalling then installing the Rake gem in my computer's Ruby, RVM Ruby-2.1.0, the RVM Ruby-2.1.0#global, and the RVM gemset that I created for the specific project. I've also tried removing the Gemfile.lock and then bundle installing.
I've tried to manually run rake out of the terminal in multiple different Ruby/gems files including RVM. It gives this error:
/Users/me/.rvm/gems/ruby-2.1.0/gems/rake-10.1.1/bin/rake ; exit;
~ me$ /Users/me/.rvm/gems/ruby-2.1.0/gems/rake-10.1.1/bin/rake ; exit;
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
I have a Rakefile in my project and have tried renaming it as well (Rakefile.rb, rakefile).
When I run Rake commands such as rake db:migrate, I get this error:
rake aborted!
undefined local variable or method config' for main:Object
/Users/me/RailsProject/config/environment.rb:4:in'
/Users/me/.rvm/gems/ruby-2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in require'
/Users/me/.rvm/gems/ruby-2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:inblock in require'
/Users/me/.rvm/gems/ruby-2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in load_dependency'
/Users/me/.rvm/gems/ruby-2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:inrequire'
/Users/me/.rvm/gems/ruby-2.1.0/gems/railties-4.0.2/lib/rails/application.rb:189:in require_environment!'
/Users/me/.rvm/gems/ruby-2.1.0/gems/railties-4.0.2/lib/rails/application.rb:250:inblock in run_tasks_blocks'
/Users/me/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in eval'
/Users/me/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
I've looked everywhere for the solution before coming here, but I could not find it. I would be appreciative if someone could give me some advice on this issue. Thank you in advance.
Looks like it it having trouble finding dependencies. Have you installed rake on your system with gem install rake? If not you will need to use bundle exec rake.
I don't know what the problem was, but I solved it by creating a new gemset, installing Rake to it, and using it. I also switched from Rubymine to Sublime. It may have been Rubymine trying to use a different gemset. Beware of those IDE settings.

Rails seed file not loading for me in production profile after 3.16 and capistrano 3.1 upgrade

I have an app that I have been in happily developing for some time, and haven't had any trouble seeding the production database with my seed file until recently, as I have been attempting to get capistrano deployment working, which spawned an upgrade and gem dependency exercise;-first I blamed capistrano but this behavior happens locally.
So if I reset and seed with:
RAILS_ENV=production rake db:reset
and I end up with tables being undefined that the seed file is attempting to load: e.g:
...tables being built:
.
.
.
-- initialize_schema_migrations_table()
-> 0.0037s
-- assume_migrated_upto_version(20140117153600, ["/Users/jaytho/Projects/1.1.1-a1.dev.merge_test/db/migrate"])
-> 0.0020s
BankCards
rake aborted!
uninitialized constant BankCard
/Users/jaytho/Projects/1.1.1-a1.dev.merge_test/db/seeds.rb:7:in block (2 levels) in <top (required)>'
/Users/jaytho/Projects/1.1.1-a1.dev.merge_test/db/seeds.rb:6:inblock in '
/Users/jaytho/Projects/1.1.1-a1.dev.merge_test/db/seeds.rb:4:in <top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p448#global/gems/railties-3.2.16/lib/rails/engine.rb:525:inload'
/usr/local/rvm/gems/ruby-1.9.3-p448#global/gems/railties-3.2.16/lib/rails/engine.rb:525:in load_seed'
/usr/local/rvm/gems/ruby-1.9.3-p448#global/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:347:inblock (2 levels) in '
/usr/local/rvm/gems/ruby-1.9.3-p448#global/gems/activerecord-3.2.16/lib/active_record/railties/databases.rake:290:in `block (2 levels) in '
Tasks: TOP => db:setup => db:seed
(See full trace by running task with –trace)
of which BankCard is the first table seeds.rb is attempting to populate. Comment out BankCard and it just goes to the next table.
The db:reset command works perfectly with in the other environments:
RAILS_ENV=development rake db:reset
and
RAILS_ENV=test rake db:reset
a downgrade to 3.2.15 did not help. I also attempted many permutations like:
bundle exec rake db:reset RAILS_ENV=production
RAILS_ENV=production bundle exec rake db:drop db:create db:migrate db:seed
and I even wiped all my migrations and tried just from the schema thinking that a mangled migration silently causing an issue:
RAILS_ENV=production bundle exec rake db:schema:load db:seed
without any luck- exact same answer.
I also attempted to extract the seed.rb routines into a separate rake task- same result.
The brain twister for me is that if I call the seeds.rb from the console:
'echo load “db/seeds.rb”' | RAILS_ENV=production rails c
she loads without any issues. It works from the console.
I attempted to get into databases.rake and try and recreate the environment there to duplicate the environment into my own rakefile; however, since calls into databases.rake exhibit the same problem, I am pretty much stuck between a rock and a hard place.
What can I be doing wrong to pollute only the production environment? How can I debug this?
Thanks in advance. Beer is on me if you ever are in Dallas.
After some insomnia and some more varied google searches I stumbled on this website: http://community.activestate.com/node/9065 and
Rails 3.2.11 asset precompile fails if threadsafe! enabled where they give clues that threadsafe is important.
Sure enough; if I comment out the threadsafe line in config/environments/production.rb:
# Enable threaded mode
# config.threadsafe!
My rake db:seed tasks work in production.
the solutions in those articles, for some reason didn't work. I ended up doing this to fix it in config/environments/production.rb
# Enable threaded mode
config.threadsafe! unless $rails_rake_task
I hope this helps somebody else out who is upgrading.

Rake commands aborted / Ruby Rails

I'm pretty sure I should be posting this here, but feel free to correct me if this belongs on something like Superuser.
Trying to setup this Ruby/Javascript app https://github.com/jamesu/tubehub - on my freshly formatted Linode.
Running: Ubuntu v10.04 LTS, Ruby v1.8.8dev, Rails v3.2.9, SQLite v3.6.22.
I appear to be close to successfully installing and launching this app after much troubleshooting, but the last bit I can't figure out yet is the "aborted" errors I get when running the rake commands, as shown in the README documentation.
root#li570-120:~/tubehub# rake db:seed
rake aborted!
/root/tubehub/util.rb:8: undefined (?...) sequence: /^(.*?)((?<!&)#|\#)(.*)$/
/root/tubehub/util.rb:9: undefined (?...) sequence: /(?:\#)(?<!&#)(?:\#)*(.*)$/
/root/tubehub/core.rb:37
/root/tubehub/core.rb:36:in `each'
/root/tubehub/core.rb:36
/root/tubehub/Rakefile:2
Tasks: TOP => db:seed => environment
(See full trace by running task with --trace)
root#li570-120:~# rake db:load
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
(See full trace by running task with --trace)
This is my first foray into Ruby specifically, filtered through some "rake" docs but wasn't sure what I was looking at.
Any suggestions?
I'll add an answer.
Please use rake db:schema:load instead
As per Anatoliy Kukul's suggestion - "rake db:schema:load" got everything working correctly, and loaded all of the tables needed into the local database.
worked a treat - thanks for the clarification!

Problem with Rake while attempting to install Diaspora on Dreamhost

I am attempting to install a Diaspora pod on my Dreamhost account, following the instructions here:
https://github.com/diaspora/diaspora/wiki/Installing-and-Running-Diaspora
Everything went smooth until it was time to use Rake in order to set up the database. I created the databases using dreamhost's web interface, and then attempted the line given in the guide:
RAILS_ENV=production bundle exec rake db:migrate
The result being:
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake: Is a directory - /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake (Errno::EISDIR)
from /usr/bin/rake:19:in `load'
from /usr/bin/rake:19
It looks like some sort of Rake problem (and indeed, /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake is a directory).
I have some other homemade Ruby-on-Rails projects running on Dreamhost and have no similar problem with rake for them. Their rakefile looks a little different but I'm not sure what causes the problem.
Just a guess, would it help to set RAILS_ENV=production on the end of the line?

Resources