I have a \"user\" model. I have a list of users on the user index page with an edit button beside each. I want to click on the edit button for each user which will open a bo
The current form is not for editing the record, change it to:
users/index.html.erb
Listing users
Name
Company
Email
<% @users.each do |user| %>
<%= user.name %>
<%= user.company %>
<%= user.email %>
<%= link_to 'Show', user %>
<%= link_to 'Edit', '#', 'data-target' => "#myModal_#{user.id}", 'data-toggle' => 'modal' %>
<%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %>
<% end %>
user/_form.html.erb
<%= form_for(user, remote: true) do |f| %>
<% if @user.errors.any? %>
<%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:
<% @user.errors.full_messages.each do |msg| %>
- <%= msg %>
<% end %>
<% end %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :company %>
<%= f.text_field :company %>
<%= f.label :email %>
<%= f.text_field :email %>
<%= f.submit %>
<% end %>
If you want clicking the submit to refresh the entire page, just remove remote: true from the _form.html.erb