ruby - undefined method `refreshProfile_affinity_path' for #<#<Class:0x8daee70>:0x8dbdc30> -
i'm getting error in title. not sure how write routes, controller, , index.
i trying create 'refresh' button in index.html.erb
view shown below:
... <td><%= link_to 'refresh', refreshprofile_affinity_path(a), method: :put %></td> ...
it using route in routes.rb
:
resources :affinities put 'affinities/refreshprofile/:id' => 'affinities#refreshprofile'
it trying access following method in affinities_controller.erb
:
... def refreshprofile @affinity = affinity.find(params[:id]) new_profile_affinity = user.find(@affinity.user_a_id).profile_affinity_with(user.find(@affinity.user_b_id)) if @affinity.update_attributes(:integer, new_profile_affinity) redirect_to @affinity end end ...
what wrong? appreciated!
you need add as:
route, specifies prefix helper method , why you're getting undefined method error e.g.
put 'affinities/refreshprofile/:id' => 'affinities#refreshprofile', as: 'refreshprofile_affinity'
refreshprofile_affinity_path
work, or give shorter, snappier name e.g. as: 'refreshprofile'
, use refreshprofile_path
.
Comments
Post a Comment