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
Related
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 just updated refinerycms-news engine in my Gemfile from '~> 0.9.8' to :git => 'https://github.com/resolve/refinerycms-news.git', and now there is an error caused by a missing column. The migration to create the column can be found in the installed gem, but rake db:migrate does nothing. Is there another rake task or other step that will run it?
You'll have to follow this convention for Refinery CMS:
rails generate refinerycms_news
rake db:migrate
The generator copies only new migrations in and then rake db:migrate runs them.
Cheers,
Phil
I am currently making my way through the Ruby on Rails tutorial over at http://ruby.railstutorial.org/ and I am trying to migrate the demo_app database to heroku.
heroku rake db:migrate
rake aborted!
unable to open database file
I have read on other stackoverflow posts that some people fixed this by entering
group :production, :staging do
gem "pg"
end
group :development, :test do
gem "sqlite3-ruby", "~> 1.3.0", :require => "sqlite3"
end
in the gemfile. I also entered it into my gemfile and then deleted my old gemfile.lock and redid my bundle install AND rake db:migrate command. I am still receiving the same error.
I am obviously brand new to ruby, rails and heroku but I understand that the problem seems to be that I am using sqlite locally and postgresql in production (on heroku). Do I now have to install this postgresql onto my machine and then RE-migrate the DB? I am afraid I will not be able to get much more out of the tutorials (or ruby on rails itself) if I cannot use heroku.
Kill it!
I was having the same problem and found no solutions. I think something we are doing in those tutorials is leading us to mangle the database.yml file that heroku generates.
I ended up destroying my heroku app
heroku destroy
and then creating a new one, pushing a fresh copy, and running
heroku create
git push heroku master
heroku rakedb:migrate
This time everything worked fine! Just make sure you have the pg gem in your gemfile for production
group :production do
gem "pg"
end
and add config/database.yml to your .gitignore file too for good measure.
or if it's working ok locally do a heroku db:push to magically put your local sqlite DB into Heroku's postgresql db.
I always work with the same DB platform locally just so I don't run into any differences (usually only when you start doing DB specific SQL) so I run Postgresql locally too.
Had the same problem... with Heroku interface... ran:
heroku rake db:migrate --trace
and found the problem to be with faker, not being found...Since 'faker' in our Gemfile is loaded in the development group, I loaded it in the production group as well.
saved Gemfile
bundle install
git add .
git commit -m "fixed faker"
git push
git heroku push
heroku rake db:migrate
heroku rake db:populate
now everything works...the QUESTION, now is what to do with 100 users on my production site?
At least I can continue with Hartl's tutorial!!
I just cloned a github repo on a fresh Ubuntu machine, running sqlite3 for all environments. rake db:create says development.sqlite3 already exists. rake db:migrate says I'm missing a bunch of required gems and should run rake gems:install. rake gems:install, of course, says it Could not find table 'studies', which sounds to me like something rake db:migrate should fix.
I looked around the net and while lots of people have gotten 'could not find table' errors, they all got them from rake db:migrate, not rake gems:install. I'm suspecting it's an application-specific error, but still, any ideas would be appreciated.
PS: Ruby 1.8.7, Rails 2.3.8.
You can always install separate gems with gem install -r <gem name> or gem install -v=<gem version> -r <gem name> command, not using rake.
Is this a Rails 3 app? If so, you should run:
bundle install
Rails 3 uses Bundler instead of the rake tasks to manage gems. http://gembundler.com/
Did you try running with the trace option? Might help pin down the failing gem:
rake -t gems:install
I am trying to install and run Spree on my local machine by following the steps mentioned in Getting started with Spree
However, when I start the server I get the following error:
Could not find table 'pages'
Can someone please help me out with this?
Solved the issue!
Generated the following generators:
spree_static_content and spree_product_assembly which did the magic!
Could not find table 'pages' means rails is not being able to find that table in the database.
In those instructions, review the section 'configuring the database' and then '4.6 Populating the Database'.
It sounds like you want to give spree a go, but don't have experience with Rails.
The spot where you are stuck is not something specific to spree, its a step required in setting up all rails projects referred to as database migration.
For what you need to know about migrations the official Rails Guides are great.
http://guides.rubyonrails.org/migrations.html
For a comprehensive intro to Rails which may also answer a few of your other questions, check out http://railstutorial.org/ruby-on-rails-tutorial-book
If you just want to try stuff.. the spree tute is on track
Do these steps again..
(If it generates an error, to a rake db:drop first to get rid of what you have already done)
rake db:create
rails g spree:site
rake spree:install
rake spree_sample:install
rake db:bootstrap
rake db:migrate
rake db:seed
rake db:sample
rake db:admin:create
Here is what I did to get Spree up and running:
Create a new rails project:
$ rails new spree_project
Add these 5 gems to the projects Gemfile (/spree_project/Gemfile):
gem 'spree', :git => 'git://github.com/spree/spree.git'
gem 'spree_auth_devise', :git => 'git://github.com/spree/spree_auth_devise'
gem 'spree_gateway', :git => 'git://github.com/spree/spree_gateway.git'
gem 'spree_usa_epay'
gem 'spree_skrill'
Run a bundle install and setup the database (rake db:bootstrap did not work for me)
$ bundle install
$ rake db:migrate
$ rake db:seed
$ bundle exec rake spree_sample:load
The 'pages' table is used by the spree_static_content gem. You can either remove the gem from your gemfile, or you can generate migrations for the static content gem:
rails generate spree_static_content:install
If you've included the 'spree_product_assembly' gem as well, you'll want to do the same for it:
rails generate spree_product_assembly:install
Then, reset the database (just to make sure)
rake db:bootstrap
rake db:admin:create
I ran into similar issues after trying the http://spreecommerce.com/documentation/getting_started.html instructions, but it seems to have created a nice demo app after taking these additional steps.