Использую rails 4 и ruby 2.0.0
Установил gem 'acts_as_commentable' все нормально прошло, прописал
class Post < ActiveRecord::Base
acts_as_commentable
end
Создал контроллер
class CommentsController < ApplicationController
def create
comment = Comment.new comment_params
commentable = params[:comment][:commentable_type].constantize.find(params[:comment][:commentable_id])
comment.commentable = commentable
comment.user = current_user
comment.save
redirect_to [commentable.user, commentable]
end
private
def comment_params
params.require(:comment).permit!
end
end
добавил во вьюху:
<%= form_for(Comment.new) do |f| %>
<div class="row">
<div class="large-1 columns">
</div>
<div class="large-11 columns text-left">
<%= form_tag "/posts/add_new_comment" do %>
<%= hidden_field_tag "id", post.id %>
<%= text_area_tag "comment[comment]" %>
<%= submit_tag "Post Comment" %>
<% end %>
по примеру
www.arailsdemo.com/posts/16 но там пост за 2010 год, а рельсы ругаются на undefined method `pending?' for #