Hi all i'm getting this error when I try to post a comment on a post.
The error
Cannot redirect to nil!
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:1104:in `redirect_to'
/Users/Mister/dev/blog/app/controllers/comments_controller.rb:9
Comments/Controller:
class CommentsController < ApplicationController
make_resourceful do
belongs_to :galleries, :news_posts
actions :create, :destroy
response_for :create do
flash[:success] = "Comment posted."
redirect_to parent_object
end
response_for :create_fails do
flash[:error] = current_object.errors.full_messages.to_s
redirect_to parent_object
end
response_for :destroy do
flash[:success] = "Comment deleted."
redirect_to parent_object
end
end
end
routes
map.resources :posts, :galleries, :news_posts do |commentable|
commentable.resources :comments, :only => [:create, :destroy]
end
News PostsController
class NewsPostsController < ApplicationController
make_resourceful do
actions :all
end
end
models/commment.rb
class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true
end
models/news_post.rb
class NewsPost < ActiveRecord::Base
belongs_to :home
has_many :comments, :as => :commentable, :dependent => :destroy
end
This should be really simple but can't find the solution, I'll be grateful for any help thank you