0

I'm trying to use acts as votable gem and can't understand how it actually works. I couldn't find any good workarounds or tutorials for it. I tried implementing the accepted solution mentioned here but got Routing Error. Can anyone help me out with a good tutorial or point me out how to get it to work editing the following code.

routes.rb

resources :posts do
  member do
    put "like", to: "posts#upvote"
  end
end

posts controller

def upvote
  @post = Post.find(params[:id])
  @post.liked_by current_user
  redirect_to @post
end

show.html.erb

<%= link_to "Bookmark Post", like_post_path(@post, method: :put), class: "button tiny" %>
Community
  • 1
  • 1
Shuvro
  • 1,499
  • 4
  • 14
  • 34

1 Answers1

0

method attribute should be passed to the link_to method, not the path helper, like this

<%= link_to "Bookmark Post", like_post_path(@post), method: :put, class: "button tiny" %>
Ahmad Sherif
  • 5,923
  • 3
  • 21
  • 27
  • 1
    thank you...can you please mention this to the post I mentioned so that beginners like me don't get confused. I have yet to get the reputation to comment there. – Shuvro Jan 18 '14 at 17:05