So after pushing my app to heroku, I tried to migrate database to heroku. However, I get the following error.
C:\Users\Administrator\Ruby\Myapp>heroku rake db:migrate
rake aborted!
undefined method `task' for #<MyApp::Application:0x7fc922c28dd0>
In local, everything works just fine including migration.
Also, migration worked just fine about few days ago, therefore it seems the error is after the rake version which changed from 0.8.7 to 0.9.0 in Heroku.
How can I resolve this problem?
had this problem yesterday and posted here: Rake 0.9.0 'undefined method 'task' '
Several solutions have been specified.
Try adding
gem 'rake', '0.8.7'
to your Gemfile, to control the version of Rake that Heroku uses on your app.
Related
I use the command
rake doc:app
to generate some rudimentary documentation for my rails app. It's always worked fine in the past. Yesterday I upgraded by app from Ruby 1.9.3 to 2.1.1, and Rails 3.2 to 4.1. Everything is working fine with the app, so I went to regenerate documentation for the first time in a few weeks, and it failed. I ran the command above and got the following error message:
rake aborted!
Don't know how to build task 'README.rdoc'
/home/vagrant/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
/home/vagrant/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => doc:app => doc/app/index.html
(See full trace by running task with --trace)
I believe this is the standard error message rake delivers for a task it doesn't know. Like if I ran
rake foo
It gives the exact thing, but with 'foo' instead of 'README.rdoc'. I get the same results when I run
bundle exec rake doc:app
I'm using rake 10.2.2. Any idea what's going on?
Create a README.rdoc in the project root folder. You might have removed it or replaced it with a README with another filetype extension.
I have a rails app that requires multi-table inheritance for which I am using the CITIER gem which itself requires the rails_sql_views gem to produce database views representing objects.
So far, so good. All this works like a charm on my local machine using sqlite3. When I try to deploy the application to Heroku, however, I am neither able to perform a database migration nor able to access the rails console.
The reason seems to be that the rails_sql_views gem tries to access some methods of PostgreSQLAdapter which are claimed to be non-existent. However, when I check the files of the rails repository, I can find these methods in the code. What is going on here?
When I try to run "heroku run rake db:migrate", I'll end up with the following error trace:
Running rake db:migrate --trace attached to terminal... up, run.1 rake aborted!
undefined method `tables' for class `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method_chain'
/app/vendor/bundle/ruby/1.9.1/gems/rails_sql_views-0.8.0/lib/rails_sql_views/connection_adapters/postgresql_adapter.rb:5:in `included'
/app/vendor/bundle/ruby/1.9.1/gems/rails_sql_views-0.8.0/lib/rails_sql_views/loader.rb:12:in `include'
[....]
This looks like an incompatibility between sqlite3 and postgres adapters with that gem. You should try to keep development as close to production as possible. Try installing postgress locally https://devcenter.heroku.com/articles/local-postgresql and see if you get the same error locally. If you do, consider writing a detailed bug report and sending it to the author of the Gem, or attempt to fix it yourself and send a pull request.
I'm trying to run the chapter two demo_app from the Ruby on Rails 3 Tutorial book on Heroku and it is not working. gws-demp-app.heroku.com gives the default Rails page, but gws-demo-app.heroku.com/users gives a web page that says "We're sorry, but something went wrong." On my desktop it works fine. I'm using the tools from RailsInstaller.org.
I had problems with heroku rake db:migrate at the end of the chapter not finding the activerecord-postgresql-adapter so I did install gem pg, bundle install, and updated the Gemfile and repositories. Everything is on github at https://github.com/gwshaw/demo_app.
What looks like the same problem appears at https://stackoverflow.com/questions/7619551/heroku-rake-dbmigrate-success-but-not-showing-in-app
I tried heroku restart recommended there, but that causes: Restarting processes... C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/http.rb:6
44:in `initialize': getaddrinfo: No such host is known. (SocketError)
I tried what is claimed to work, precompiling assets with bundle exec rake assets:precompile, but that generates an error: C:/RailsInstaller/Ruby1.9.2/bin/ruby.exe C:/RailsInstaller/Ruby1.9.2/bin/rake as
sets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
TypeError: Object doesn't support this property or method
(in C:/Sites/rails_projects/demo_app/app/assets/javascripts/application.js)
I'm new to ruby and rails so I'm at a loss. Any ideas?
Solved below.
Yes , this worked for me too after installing the pg gem, I ran the following:
bundle exec rake assets:precompile
git add .
git commit -am "add a note reflecting changes made"
git push
heroku create
git push heroku master
heroku rake db:migrate
heroku db:push
after invoking these commands, I was able to successfully open the demo_app on heroku.
Thanks for your post — I'm new to Rails, but reading your post helped me with a very similar issue.
Here's what worked for me:
Install pg gem to use postgreSQL on Heroku: (related article)
sudo gem install pg
Install taps gem to allow push of your local database to Heroku: (related article)
gem install taps
then the following sequence…
bundle exec rake assets:precompile
git add .
git commit -am "add a note reflecting changes made"
git push
heroku create
git push heroku master
heroku rake db:migrate
heroku db:push
If you're still having trouble, these articles are helpful too:
Stack Overflow - Heroku command: Heroku Rake db:migrate fails
Heroku - Getting Started with Rails 3.0 on Heroku/Cedar
The problem with bundle exec rake assets:precompile was the key and is solved here RoR Precompiling Assets fail while rake assets:precompile - on basically empty application.js
Oddly, Heroku wouldn't automatically precompile the assets on a git push heroku and thus would not find them. I don't think this little demo_app even uses assets, so that may be why it didn't precompile, but it still could not find applicaiton.css and failed. Once I set config.log_level = :debug in production.rb, I could see the problem in the logs. With the precompile working due to the above fix, everything worked.
I am getting an error when trying to run rake db:migrate here:
http://pastie.org/2058143
I've re-installed Rake a few times now after downgrading from Rails 3.1 RC (bad idea to upgrade to that) to Rails 3.0, which is what I'm using now.
EDIT: This was solved by doing 'gem install rake -v=0.8.7', I think I forgot to do this after I uninstalled the previous version(s) and the Rakefile was missing.
One possible solution. Open your gemlock file and delete the entire write up there and save it. if you dont have rake 0.8.7 file on your application create a new app that uses rake 0.8.7 possibly with rails 3.0.8 then copy its rake file and replace it with your previous one
I'm kinda new to this stuff, and I need some help please
I created my rails app using ruby 1.8.7/rails 2.3.8
I added Surveyor to the Gemfile.
I pushed the project to heroku.com using git, went through the normal
procedure in the "Quick Start" guide on heroku, including
$ heroku bundle install
$ heroku db:migrate
and all went through peacefully. But when I try to create a survey
using:
$ heroku rake surveyor FILE=surveys/kitchen_sink_survey.rb
I get the following error:
rake aborted!
uninitialized constant Surveyor
Can anyone help me with this please?
You will need to run rails generate surveyor:install before db:migrate
You need to also add the gem to your environment.rb
Rails::Initializer.run do |config|
config.gem "surveyor"
end