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.

enter image description here

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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -