I'm cloning a RoR app from Github. After the clone I install my gems. Now at this point my question/problem arises. Some research I've done suggests I do a
rake db:create
followed by a
rake db:migrate
I've tried both of those steps but am still having trouble.
When I run
rails console
and do something like Plan.first it returns nil. And when I try to visit my application I get an ActiveRecord::RecordNotFound in PagesController#home error alluding to the fact that it can't find the plan id of 1.
Any help is much appreciated.
Thanks in advance!
You have an empty database with no data in it, if seeds are provided - rake db:seed will help, otherwise you'll have to create initial data youself (in rails console, or may be directly in db)
Related
I am trying out an example from a book head first rails, i get to chapter 2 and i have issues following the instructions maybe because they used an older version of rails.
I am told to replace the development.sqlite3 file with the one provided on the site, and when i do so and try to run the run app again i get errors about pending migrations.
Note:
1. I already ran my migration using rake db:migrate
2. I downloaded the sqlite3 file and replaced the original file.
3. i started the server with rails s command.
4. I reload the page and then i get the error.
ActiveRecord::PendingMigrationError
Migrations are pending. To resolve this issue, run: bin/rails db:migrate RAILS_ENV=development
I have a feeling it has something to do with the schema.rb file? i dunno.
I'll really appreciate if someone can help me out here.
I have done my research, i've tried rake db:reset but to no avail. :(
see here:
[1]: http://headfirstlabs.com/books/hfrails you can scroll down to the code download section under chapter 2.
I am trying to delete an instance from a Post model on a Heroku database. From the command line, should 'heroku run Post.first.delete' work? I've been trying this and it doesn't seem to work and I can't find how to do this. All help is appreciated.
heroku run X won't directly put you into a Rails console.
As per this article you'll want:
heroku run rails console
From there you can delete records.
I'm using railshoster.de and they don't help me deploying my app.
It is this one: https://github.com/ClaudiuCreanga/your-priorities
It works in localhost.
Railshohster.de is using capistrano and passanger.
I get this error when trying to run it: We're sorry, but something went wrong.
In development.log there is no error.
What did I do:
1) Cloned my app
2) bundle install - worked well
3) rake db:schema:load and rake db:seed also worked well.
My questions are:
Where else can I look for errors?
Should it be any difference in deploying localhost vs online?
Thanks!
Finally the issue was with the table migration not being done properly and failing at some point.
I am following Michael Hartl's Rails Tutorials screen cast series and having trouble in deploying demo Rails application in Heroku. The deploy is successful but when I try to open the URl, it gives an Application Error
The link for the app is http://evening-lake-3818.herokuapp.com/ . Please Help !!
Looks like you've not used rake db:migrate
Heroku
This error is a heroku error (not a rails problem) - the typical Rails errors are the red error page, which says something like "Something went wrong" or "Page Cannot Be Found":
The error you are seeing is a Heroku problem, and is typically because you've either not set up your production database, or you have not got the required migrations to make it work.
The way to fix this is to run:
# heroku run rake db:migrate
Other than that, you'll also need to ensure you have the config/database.yml set up correctly for your production environment (which I can help you with if you need it)
I made what I now see as a mistake (better now than later, not as good as never) of running rake db:reset on my local dev env to try to solve a problem I was having with assets production compilation(RAILS_ENV=production bundle exec rake assets:precompile) referring to a PG ERROR summarized bellow.
PGError: ERROR: relation "schools" does not exist
LINE 4: WHERE a.attrelid = '"schools"'::regclass
The tables get created properly and seeding works with exception of active_admin. I use Active_Admin that did not seed properly. My emails mysteriously stopped being sent and the assets compilation for production still fails with the same error. I am not sure what I can post here to help you understand the issue but if someone could help me tackle one at a time that would be much appreciated. Here are my issues in list form.
active_admin not seeding (I tried running: rails generate active_admin:install but that started to break things further so I reverted this.
PG ERROR on assets precompile for production persists.
Email stopped being processed (not using DJ)
Env.
Rails 3.1
------UPDATE 00------
2 is Solved. db:reset dropped all my tables but only migrated and seeded my development database so I also had to:
run migrate and seed for production ( rake db:migrate RAILS_ENV="production", rake db:seed RAILS_ENV="production")
before compiling production assets(rake db:migrate RAILS_ENV="production")
I ended up splitting this question into 2 parts. The second part got better contribution and is where I found the solution for this as well.
Detailed solution here