radar/forem — Issue #129: Couldn't find Forem::Topic without an ID
Author: Akram-Khan
Created: 2012-01-09 19:02:14+00:00
State: open

I am trying to add vote_up for the posts and I keep on getting this error.

I have inherited the post controller and model of forem and written it like this :-

class PostsController < Forem::PostsController
def vote_up
begin
forem_user.vote_for(@post = Post.find(params[:id]))
render :nothing => true, :status => 200
rescue ActiveRecord::RecordInvalid
render :nothing => true, :status => 404
end
end
end

My post model looks like this :-

class Post < Forem::Post
acts_as_voteable
end

route.rb change

resources :posts do
member do
post :vote_up
end
end

added this in my forem/posts/_post.html.erb

<%= link_to t('vote for this post!'), main_app.vote_up_post_path(@post), :method => :post %>

What could be the issue? Am I doing something wrong in the routes?

Thanks,
Akram