Ruby Tutorial Chapter 5.7 -
on guide: http://guides.rubyonrails.org/getting_started.html
on topic 5.7 showing posts, after creating show.html.erb
file supposed error: activemodel::forbiddenattributeserror
when submiting form, instead nomethoderror
in posts#show
.
can tell me doing wrong, or solution this?
def postscontroller < applicationcontroller def new end def create @post = post.new(post_params) @post.save redirect_to @post end private def post_params params.require(:post).permit(:title, :text) end def show @post = post.find(params[:id]) end end
your show method private, move above private keyword in controller , should set. below..
def postscontroller < applicationcontroller def new end def create @post = post.new(post_params) @post.save redirect_to @post end def show @post = post.find(params[:id]) end private def post_params params.require(:post).permit(:title, :text) end end
Comments
Post a Comment