Thursday, 15 March 2012

ruby on rails - Pass a variable from view to controller from form submit -


I am trying to use a variable sent through the submit form.

Look for the hidden area on the line: 2

  
for form_for example, html: {multipart: true} Do F | | & Gt%; & Lt;% = f.hidden_field: tree_id ,: value = & gt; @ Tree.id% & gt; & Lt;% = f.label: new_branch_data% & gt; & Lt; Div class = "help-text" & gt; Find the file to import (.xls, .xlsx file types) & lt; / Div & gt; & Lt;% = f.file_field: Attachment% & gt; & Lt;% = f.submit "Import", Category: "BTN BTN-Primary"%> & Lt;% end% & gt;

After the kill, please submit the call taken in my controller:

  def index t = tree.find (param [[tree_id]). ...   

tree = tree (Param [[tree_ID])

"ActiveRecord :: RecordNotFound "/ could not import / tree without id

How can I fix this so that the @tree variable controller referenced in the form can be passed?

You can inspect the params found, but I think you have [ Import] then ...

  def index @ t = tree.fid (param [[import] [: tree_id]) ... ... end  

No comments:

Post a Comment