VIEW INDEX
<tr>
<td> <%= index.id %> </td>
<td> <%= index.department %> </td>
<td><%= link_to "Editar", edit_department_path(index), class:"btn btn-primary" %></td>
<td><%= button_to "Excluir",index, method: :delete, class:"btn btn-danger", data: { confirm: "Tem certeza que deseja excluir o departamento \"#{index.department}\"?"} %></td>
</tr>
VIEW EDIT
<h1 class="page-header">Atualizar Registro "<%= @department.department %>"</h1>
<%= form_for Department.new do |f| %>
<div class="form-group">
<%= f.label :departamento %>
<%= f.text_field :department, class:"form-control" %>
</div>
<div class="form-group">
<% if can? :create, Department%>
<%= f.submit_tag "Atulizar", class:"btn btn-primary" %>
<% end %>
<%= link_to "Voltar", departments_path, class:"btn btn-primary" %>
</div>
<% end %>
CONTROLLER
def new
@department = Department.new
end
def edit
id = params[:id]
@department = Department.find(id)
render :edit
end
def update
puts '###########'
puts "Método update iniciado com sucesso!"
puts '###########'
redirect_to departments_path
end
`