I see numerous posts regarding issues with deploying to Heroku, but I haven't been able to find the solution for my case. Any input would be much appreciated.
I have a blogging application that runs fine locally. However, I am returning "I'm sorry, but something went wrong" when I deploy to Heroku.
The gems I have are:
group :development do
gem 'sqlite3', '1.3.5'
end
group :production do
gem 'pg', '0.12.2'
end
The steps I've taken are:
git add.
git commit -am "latest update"
git push
git push heroku
rake db:migrate
heroku run rake db:migrate
My SQLite3 database is migrating fine, as I can find my latest blog entry (Blog.find(21)) through rails console. However, the data does not seem to be migrating to the Heroku database, as the Heroku console returns
"ActiveRecord::RecordNotFound: Couldn't find Blog with id=21."
Additionally, "heroku logs" finds:
Completed 500 Internal Server Error in 50ms
NoMethod Error (undefined method 'blogs' for nil:NilClass):
app/controllers/static_pages_controller.rb:8:in 'home'
Does this mean there could be an issue in my static_pages_controller, or is it just returning an error because the database is not migrating correctly?
Below is my static_pages controller, which works fine on my local server.
class StaticPagesController < ApplicationController
def home
if signed_in?
@blog = current_editor.blogs.build
end
@editor = Editor.first
@blogs = @editor.blogs.paginate(page: params[:page])
end
end
Note: I am using Editor.first above because I (ie. editor_id: 1) will be the only editor of my blog. I just created an Editor model to store the password_digest.
So, why isn't my application deploying on Heroku?
Any feedback would be appreciated. Also, please let me know if you need to see additional files, and I will attach.
Thanks so much!