Rails view passes wrong parameters in delete link -
below server log.
i passing user_id
, id
delete link view. when it's passed, value of user_id
15067
, id
1010
while check params putting pry method, value of id
replaced user_id
i.e. 15067.
here whole workflow:
routes
delete "users/delete_role_sub_field" => "users#delete_role_sub_field"
controller:
def delete_role_sub_field // code destroy end
view:
<% @user.roles.each_with_index |role, i| %> <tr> <td> <a class="delete remove-description-field" href="/users/delete_role_sub_field?user_id=<%= @user.id %>&id=<%= role.id %>" data-method="delete" method="delete" data-confirm="are sure want delete role field?"> delete </a> </td> </tr> <% end %>
any appriciated!
thanks in advance.
can post link_to
function? u passing params, because application works fine, if on route see first params , what's second.
example:
resources :magazines resources :ads end
that generate route this:
/magazines/:magazine_id/ads/:id
link_to this:
link_to ads.title, magazines_ads_path(magazine.id, ads.id)
and in show action:
def action @ads = magazine.find(params[:magazine_id)).ads.find(params[:id]) end
Comments
Post a Comment