lundi 27 avril 2015

passing parameters between views and controllers ruby 1.8.7

i have this form nested in view 'A'

<div>
<%if current_user%> 
    <%=form_for(ModelB.new) do |f|%>
      <%if (params[:param_to_check].present?)%>
        <%f.hidden_field "param1",:value=> @modelA.id%>
        <%f.hidden_field "param2",:value=> current_user.id%>
      <%end%>
    render button
    <%end%>
<%else%>
    render other butotn
<%end%>

</div>

and this 'find' in Bs_controller:

@modelA=ModelA.find_by_id(params[:param1])
  :option_from_specific_gem=> -(@modelA.wanted_value).abs

when i look to the params passed to the Bs_controller i see:

Parameters: {"authenticity_token"=>"some_hash=", "utf8"=>"✓", "y"=>"42", "x"=>"144"}

and i need to pass the hidden_field's valies to Bs_controller.

thx for the atention :)

here is the gist: http://ift.tt/1bwLNEw

Aucun commentaire:

Enregistrer un commentaire