0
votes

I followed the steps indicated in this answer for setting up thumbs_up

https://stackoverflow.com/a/4963297/1643048

However I keep getting this error and have no idea how to fix it:

No route matches {:action=>"vote_up", :controller=>"posts", :id=>nil}

Can anyone help?

UPDATE:

exact error-

Routing Error

No route matches {:action=>"vote_up", :controller=>"posts", :id=>nil}

Try running rake routes for more information on available routes.

config/routes.rb:

Projectmadrone::Application.routes.draw do
  devise_for :admins
  #devise_for :users
  devise_for :users do get '/users/sign_out' => 'devise/sessions#destroy' end
  resources :posts do
    member do
        post :vote_up
       end
     end
  root :to => 'posts#index'
 end

my view: app/views/posts/index.html.erb

<li><%= link_to('vote for this post!', vote_up_post_path(@post), :method => :post) %></li>
1
Could you post the exact content of your "config/routes.rb" as well as the context/sorrounding lines of the server-log regarding this error?spaudanjo

1 Answers

0
votes

Your @post-variable seems to be nil. Propably because you are using it in the index-view instead of the show-view. So you should try to put the link_to-code into the app/views/posts/show.html.erb.