私が追加しようとしているのは、押されると「精度」の値が1ずつ増えるボタンです。私はたくさんのStackOverflowソリューションを見てきましたが、彼らはこれまで私のために働いてきました。私は同僚のコードを使って作業しています。役立つならば、そのほとんどはRuby on Railsの教科書( "Learn Rails by Example")から取り上げられ、一緒にハッキングされるかもしれません。Ruby on Rails 3投票システムのルーティングエラー
resources :users do
resources :comments
resources :posts
end
resources :posts do
resources :comments
match "vote_up", :on => :collection
match "vote_down", :on => :collection
end
私が受け取るエラーは次のとおりです:
http://localhost:3000/posts/vote_up?id=1
CanCan::AccessDenied in PostsController#vote_up
You are not authorized to access this page.
Parameters:
{"id"=>"1"}
よう
def vote_up
#in posts_controller.rb
@post = Post.find(params[:id])
@post.rate_it(1, current_user.id) #with "acts_as_rateable" plugin
@post.save
私のルーティングが見えます:
<%= link_to 'Accurate2', :action => :vote_up, :id => @post.id%>
私のコードは次のようになりますように
私の見解に見えます
CanCanの宝石と何か関係があるようです。どのように正確にあなたがそれを使用しているか知るのに役立つでしょう。 –