I am trying to create my first ever program Using Ruby programming
language on Ruby on Rails and it is a blog! I am following a tutorial
and have created a comments box which does NOT print the comment on the
page so far when written in the comments box, that’s the problem. I will
explain step by step I have:
- Called out on routes.rb:
resources :posts do
resources :comments
end
-
Called out using Cmder:
rails g controller comments create destroy -
This is my comments_controller.rb class:
class CommentsController < ApplicationController
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.build(params[:comment]) #around here is
the error
@comment.save
redirect_to @post
end
def destroy
end
end
can anybody please help?