Вопрос

I'm trying to implement the thumbs_up gem into my app and I keep getting this error even though I have a route for the vote_up action

My posts controller looks like

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

My route looks like

   resources :posts do
     get :vote_up, :on => :member
     resources :comments
   end

I don't know what the problem is, if anyone could help me or point me to a tutorial to use the thumbs_up gem that would be great.

Это было полезно?

Решение

The problem is that you're requesting vote_up without an id for a post. Just looking at your controller:

current_user.vote_for(@post = Post.find(params[:id]))

Yet I do not see any id field in your request. The problem lies in your view.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top