Ruby on Rails Saturday, August 30, 2014

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:

1. Called out on routes.rb:

resources :posts do
resources :comments
end

2. Called out using Cmder:
rails g controller comments create destroy


3. 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?

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/335bf9a03da77a47707ee83e516d92d4%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment