ruby on rails - How to pass parameters to the controller with the proper key -
i'm trying figure out how store id on controller side delete store.
currently code params on controller side sends store.id(1) value key format. need retrieve store_id: instead.
{..."controller"=>"home", "action"=>"delete_store", "format"=>"1"} what need:
{..."controller"=>"home", "action"=>"delete_store", "store_id"=>"1"} html/erb:
<h4>your stores:</h4> <% @my_stores.each |store| %> <p><%= store.name %><%= link_to "x", delete_store_path(store.id), method: :delete %></p> <% end %> controller:
class homecontroller < applicationcontroller ... def delete_store # current code, have # current_user.stores.where(store_id: params[:format] ) # make proper need # current_user.stores.where(store_id: params[:store_id] ) end end
you can in params hidden_field_tag:
<%= hidden_field_tag :store_id, store.id %> this should allow lookup like:
params[:store_id] here link apidock wanting more info on hidden_field_tag. http://apidock.com/rails/actionview/helpers/formtaghelper/hidden_field_tag
Comments
Post a Comment