I continue to get this error message in my Papertrail logs when I try to access my URL /guestbooks.
This route works great on localhost, but not on Heroku. Are my rails naming conventions off? I think they are right, but I could be mistaken.
I tried running rake db:rest
, I then tried running rake db:drop db:create db:migrate
, which showed that I was getting errors in my migration files, so I deleted them and then ran the command again and no longer received the migration files error from PG.
I tried committing my changes and running heroku run rake db:migrate
, but my error persisted. Below are my MVC and routes.
class GuestbooksController < ApplicationController
before_action :load_page
def index
@guestbook = Guestbook.new
end
def create
@guestbook = Guestbook.new(guestbook_params)
if @guestbook.save
flash.now[:notice] = "Thanks for taking the time to write us! We greatly appreciate it!"
render :index
else
flash.now[:notice] = "Your message failed to post, please try again"
render :index
end
end
private
def load_page
@guestbooks = Guestbook.page(params[:page])
end
def guestbook_params
params.require(:guestbook).permit(:name, :email, :message)
end
end
My schema
create_table "guestbooks", force: :cascade do |t|
t.string "name"
t.string "email"
t.text "message"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
My model
class Guestbook < ActiveRecord::Base
paginates_per 5
end
The issue was that I didn't have any migrations (only schema.rb). You can remove all migrations if you want, but if you do, you need to run rake db:setup to use schema.rb to setup the database (rake db:reset will only look for migrations).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.