user558138
user558138

Reputation: 167

passing values from view to controller

I have two comboboxes and one file_field in the view file. I want to save the values of the selected values in the comboboxes and the path of the file selected and send these values back to controller. How can I do it?

<% form_for :path, :url => {controller => "users", :action => "receive_file"} do |f| %>

  <div align='center' >

    <font color='black'><b>Select Skillset:</b>
      <%= collection_select(:video, :category_id, @technologies, :id, :SkillSetName) %>
    </font>
    <br><br><br><br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <font color='black'><b>Select Topic:</b>
      <%= collection_select(:video, :category_id, @technologies, :id, :Topic) %> 
    </font>
    <br><br><br><br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <%= file_field "person", "photo" %>
    <br><br>
    <%= submit_tag "Append", :style=>"height: 25px; width: 100px"%>
    &nbsp;
    </td>
  </div>
<%end%>

Upvotes: 1

Views: 2885

Answers (1)

amit_saxena
amit_saxena

Reputation: 7624

That's what forms are for. Please note that it is a separate request and you can embed all you data as form fields in the view. Once the user clicks on submit, all the fields of the form will be available in the params hash in the controller action (to which the form is submitted)

http://guides.rubyonrails.org/form_helpers.html

Upvotes: 2

Related Questions