I am working on a sign up application for presentations in Ruby on Rails. As such, I am displaying a list of available presentations, with the last column displaying a button to register for that specific presentation.
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">Name</th>
# ...
</tr>
</thead>
<tbody>
<tr>
<% @presentations.each do |pres| %>
<td scope="row"><%= pres.Name %></td>
# ...
<td scope="row">
<% unless @current_student.Selected == pres.Titel %>
<%= form_tag students_select_path do %>
<%= submit_tag "Choose", class: "btn", value: pres.Title %>
<% end %>
</td>
</tr>
</tbody>
</table>
I would like the button to say "Choose"
, then send off the parameter pres.Title
to a function that I have defined. For some reason, the button in the table shows the value of pres.Title
, and not of "Choose"
. How can this be fixed?
Current working implementation:
def addtodb
@student = Student.find_by(id: session[:student_id])
if @student.Selected == nil
prestitle = params[:commit]
@schueler.update_attribute(:Selected, prestitle)
redirect_to students_select_path
end
end