how to set multiple default form values on submission in rails? - ruby-on-rails

attendance table that takes has attribute status, date,recuritment_id, and project_site_id .
project_site has one_to_many association with attendance
recuritmenthas one_to_many association with attendance.
i am taking attribute from recruitment table when attribute status is joined in attendance#form view.
<% (1..(Time.days_in_month #project_site.attendance_month.strftime("%m").to_i)).each do |date| %>
here #project_site.attendance_month contains the attendance month value. based on month i calculate number of days column along with name from recuritmnet table.
here is view-
holydays master contains corresponding month holyday's date and in view it auto match date and prints "H",
All input default selected as P. there is final submission_button that chnages boolean attribute. now on final submission i want to push all default selected P into attendance table.
attendance_controller.rb
def new
if #project_site.submission_status == false
#attendance = Attendance.new
#date = HolydayCalendar.all
#recruitment = Recruitment.all.where(current_status: "2")
else
redirect_to project_site_attendances_path
end
end
from.html.erb (attendance controller view)
<table>
<thead>
<tr>
<th class="attendance-emp-name">Emp. Name</th>
<% (1..(Time.days_in_month #project_site.attendance_month.strftime("%m").to_i)).each do |date| %>
<th class="text-center"><%= date %></th>
<% end %>
</tr>
</thead>
<tbody>
<% #recruitment.where(location: #project_site.site_id).each do |recruitment| %>
<tr>
<td class="attendance-emp-name"><%= recruitment.name %></td>
<% (1..(Time.days_in_month #project_site.attendance_month.strftime("%m").to_i)).each do |date| %>
<%= form_with(model: attendance, :html => {:id => 'attendance-form-validation'}, url:[#project_site, #attendance], local: true) do |f| %>
<% if HolydayCalendar.find_by(date: (#project_site.attendance_month.strftime("%Y-%m")+"-"+date.to_s), total_site_id: #project_site.site_id)%>
<td class="holyday text-center"><%= "H" %></td>
<% elsif recruitment.attendances.find_by(attendance_date: (#project_site.attendance_month.strftime("%Y-%m")+"-"+date.to_s)) == nil %>
<td>
<%= f.select :status, [['P', 1], ['A', 2], ['L', 4], ['WE', 5], ['CO', 6]], {}, { onchange: 'this.form.submit()', class: 'attendance-select-input' } %>
</td>
<% else %>
<% attendance_value = recruitment.attendances.find_by(attendance_date: (#project_site.attendance_month.strftime("%Y-%m")+"-"+date.to_s)) %>
<%if attendance_value.status == 1 %>
<td class="presant text-center"><%="P" %></td>
<% elsif attendance_value.status == 2 %>
<td class="absent text-center"><%="A" %></td>
<%elsif attendance_value.status == 3 %>
<td class="holyday text-center"><%="H" %></td>
<%elsif attendance_value.status == 4 %>
<td class="leave text-center"><%= "L" %></td>
<%elsif attendance_value.status == 5 %>
<td class="weekend text-center"><%= "WE" %></td>
<%elsif attendance_value.status == 6 %>
<td class="compoff text-center"><%= "CO" %></td>
<% end %>
<% end %>
<%= f.hidden_field :attendance_date, value: (#project_site.attendance_month.strftime("%Y-%m")+"-"+date.to_s)%>
<%=f.hidden_field :recruitment_id, value: recruitment.id%>
<%=f.hidden_field :project_site_id, value: #project_site.id%>
<% end %>
<% end %>
</tr>
<% end %>
</tbody>
</table>
<% if #project_site.submission_status == true %>
<div class="text-center">
<%= link_to "Submit Attendance", set_submission_status_project_site_path(#project_site), method: :put, data: { confirm: 'Make Sure you marked all attendance before submission' }, :class=>"button primary disabled" %>
</div>
<% else %>
<div class="text-center">
<%= link_to "Submit Attendance", set_submission_status_project_site_path(#project_site), method: :put, data: { confirm: 'Make Sure you marked all attendance before submission' }, :class=>"button primary" %>
</div>
<% end %>
project_sites_controller.rb
def set_submission_status
#project_site = ProjectSite.find(params[:id])
#project_site.update(submission_status: true)
end

It's a little unclear what your question is, but I gather it has to do with your form sending back an array op options.
If you want your html form to return an array of information, then you need to indicate it in your html using the name = "attendance[]" syntax, notice the square brackets.
Check out this article on the subject https://mattstauffer.com/blog/a-little-trick-for-grouping-fields-in-an-html-form/

Related

Search data by first_name and last_name

I am trying to search the data that comes from two different models via another raport model. I need to filter the data listed in the index view by the user's first and last name.
##How can I search and display only the filtered data in data_filter.html.erb view?
## in raports/index.html.erb:
<div>
<div class="" id="pro_content">
<div class="main_container">
<p id="notice"><%= notice %></p>
<h1>Raports </h1>
<hr>
<%= button_to "Filter the data", {:controller => 'raports',:action=>'data_filter'},class: "btn btn-primary kerkes1", :method => "get" %>
<table class="table ">
<thead>
<tr>
<th>User</th>
<th>Vacation type</th>
<th>Start Data</th>
<th>End Data</th>
<th>Ditet</th>
<td>status</td>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% #vacation_requests.each do |vacation_request| %>
<tr class="<%= vacation_request.request_level%>">
<td>
<% #home.each do |u|%>
<% if u.id == vacation_request.user_id%>
<%= u.first_name + " "+ u.last_name%>
<%end%>
<%end%>
</td>
<td>
<% #v_r.each do |vr|%>
<%if vr.id == vacation_request.vacation_type_id %>
<%= vr.vacation_type%>
<% end end%>
</td>
<td><%= vacation_request.start_data %> </td>
<td><%= vacation_request.end_data %></td>
<td>
<%=vacation_request.skip_holidays%>
</td>
<% if vacation_request.request_level == "accepted"%>
<td style = "color: green"><i class="fa fa-check"></td>
<%elsif vacation_request.request_level == "rejected" %>
<td style = "color: red"><i class="fa fa-times"></i></td>
<%else%>
<td style = "color: #daa520"><i class="fa fa-hourglass-half"></td>
<%end%>
<!-- <td><%= vacation_request.description %></td> -->
<td><%= link_to 'Show', vacation_request %></td>
<td><%= link_to 'Destroy', vacation_request, method: :delete, data: { confirm: 'Are you sure?' } %></td>
<!-- <td><%= link_to 'Edit', edit_vacation_request_path(vacation_request) %></td>
<td><%= link_to 'Destroy', vacation_request, method: :delete, data: { confirm: 'Are you sure?' } %></td> -->
</tr>
<% end %>
</tbody>
</table>
<br>
<p>
Shiko ne formatin Excel: <br>
<%= button_to "Excel ",raports_path(format: "xls") ,class: "btn btn-primary ", :method => "get" %>
</p>
</div>
</div>
</div>
<div style="clear:both"></div>
<div style="clear:both"></div>
##In raport.rb:
def client_full_name
"#{User.first_name} #{User.last_name}"
end
def self.search_by_client_full_name(query)
where("(User.first_name || User.last_name) LIKE :q", :q => "%#{query}%")
end
In raports_controller.rb
def data_filter
#ndalo_userin = User.find(session[:user_id])
if #ndalo_userin.status.to_i == 1
redirect_to root_path
end
#home=User.all
#useri = User.find(session[:user_id])
#adminRequest =VacationRequest.where(:request_level => "to_admin")
#vacation_types = VacationType.all
#vacation_requests = VacationRequest.all
if params[:search]
#home = User.search_by_client_full_name(params[:search])
else
#home = User.all
end
# head 404 if #users.blank?
# #raport=Raport.new
end
In data_filter.html.erb
<h3>Search for vacations by fullname </h3>
<%= form_tag raports_path, :method => :get do %>
First_Name:<%= text_field_tag :first_name, params[:first_name]%>
Last_name:<%= text_field_tag :last_name, params[:last_name]%>
<%=print%>
<%= submit_tag "Search", :client_full_name => nil , :class => "btn btn-primary"%>
<%end%>
## how can i search for a certain user displayed in raports/index.html.erb even though firs_name and last_name are not saved in the report model just in user model?
You don't need User.first_name in the query. Also, you need to quote the search string.
def self.search_by_client_full_name(query)
where("first_name LIKE :q OR last_name LIKE :q ", q: "'%#{query.downcase}%'")
end
Use ILIKE or downcase the search string
def self.search_by_client_full_name(query)
where("first_name ILIKE :q OR last_name ILIKE :q ", q: "'%#{query}%'")
end
The first name and last name is only in the user.rb model
You are calling the method on User class
User.search_by_client_full_name(params[:search])
You should move the method to User model
NOTE
Also, This should be in User model
def client_full_name
"#{first_name} #{last_name}"
end

Search form don't update table in RoR

I'm trying to write a filter for the table. Here is the code:
.../models/message.rb
Class Message < ActiveRecord::Base
include Filterable
belongs_to :user
default_scope -> { order('created_at DESC') }
validates :user_id, presence: true
validates :content, presence: { message: "Выберите файл послания для загрузки!" }, file_size: { less_than_or_equal_to: 20.megabytes }
validates :fromdate, presence: true
validates :tilldate, presence: true
mount_uploader :content, ContentUploader
scope :id, -> (id) {where id: id }
scope :tariff, -> (tariff) { where tariff: tariff }
scope :status, -> (status) { where("status like ?", "#{status}%")}
end
.../controllers/concerns/filterable.rb
module Filterable
extend ActiveSupport::Concern
module ClassMethods
def filter(filtering_params)
results = self.where(nil)
filtering_params.each do |key, value|
results = results.public_send(key, value) if value.present?
end
results
end
end
end
.../controllers/messages_controller.rb
...
def index
#messages = Message.filter(params.slice(:id, :tariff, :status)).paginate(page: params[:page], :per_page => 10)
end
...
.../views/messages/index.html.erb
...
<table class="table table-bordered">
<thead>
<tr>
<th>Клиент</th>
<th>№</th>
<th>Дата</th>
<th>Послание</th>
<th>Тариф</th>
<th>Показ с</th>
<th>до</th>
<th>Стоимость, р.</th>
<th>Статус</th>
<% if current_user.admin? %>
<th>Модератор</th>
<% end %>
</tr>
</thead>
<tbody>
<tr>
<%= form_tag messages_path, method: "get" do %>
<td><%= text_field_tag "client" %></td>
<td><%= text_field_tag "id", nil, size: 1 %></td>
<td></td>
<td><%= submit_tag "Выбрать" %><br><br><%= button_tag "Очистить" %></td>
<td><%= select_tag "tariff", options_for_select(["", "1. Вечер", "2. Весь день", "1001. ВЕЧЕР БЕСПЛАТНО", "1002. ДЕНЬ БЕСПЛАТНО"]), {} %></td>
<td></td>
<td></td>
<td></td>
<td><%= select_tag "status", options_for_select(["", "В обработке", "Исполняется", "Отклонена", "Выполнена"]), {} %></td>
<td></td>
<% end %>
</tr>
<%= render #messages %>
</tbody>
</table>
</div>
...
.../views/messages/_message.html.erb
...
<% case message.status
when "В обработке"
#messagecolor="warning"
when "Исполняется"
#messagecolor="success"
when "Выполнена"
#messagecolor="info"
when /Отклонена.*/
#messagecolor="danger"
end
unless message.moderator.nil?
#moderator = User.find(message.moderator).name
end
%>
<tr class=<%= #messagecolor %> data-message_id="<%= message.id %>">
<% if current_user.admin? || current_user.role == "Модератор" %>
<td><%= message.user.name %></td>
<% end %>
<td><%= message.id %></td>
<td><%= message.created_at.strftime("%d/%m/%Y %T %z") %></td>
<td><img src="<%= message.content_url(:thumb) %>" data-toggle="modal" data-target="#myModal" data-content="<%= message.content_url%>"></td>
<td><%= message.tariff %></td>
<td><%= message.fromdate.strftime("%d/%m/%Y") %></td>
<td><%= message.tilldate.strftime("%d/%m/%Y") %></td>
<td><%= message.cost %></td>
<td class="status">
<%= message.status %>
<% if (current_user.admin? || current_user.role == "Модератор") && message.status == "В обработке" %>
<br>
<div class="btn-group">
<button type="button" class="btn btn-success" data-status="Исполняется" data-message_id="<%= message.id %>">Принять</button>
<button type="button" class="btn btn-danger" data-status="Отклонена" data-message_id="<%= message.id %>">Отклонить</button>
</div>
<% end %>
<% if (current_user.admin? || current_user.role == "Модератор") && message.status == "Исполняется" %>
<br>
<%= link_to "Изменить", edit_message_path(message.id), :class => "btn btn-info" %>
<% end %>
</td>
<% if current_user.admin? %>
<td class="moderator">
<%= #moderator %><br>
<%= message.updated_at.strftime("%d/%m/%Y %T %z")%>
</td>
<% end %>
</tr>
...
The filter only works after the page is refreshed. It is worth to get back to the page through the menu - the form button does not work, update by F5 - it works. Why?
I will also be grateful if you tell me how to save the selected filter values ​​in the fields after it is applied.
I found the answer to my main question: it need to include the entire table into the form in .../views/messages/index.html.erb
...
<%= form_tag messages_path, method: "get" do %>
<table class="table table-bordered">
<thead>
<tr>
<th>Клиент</th>
<th>№</th>
<th>Дата</th>
<th>Послание</th>
<th>Тариф</th>
<th>Показ с</th>
<th>до</th>
<th>Стоимость, р.</th>
<th>Статус</th>
<% if current_user.admin? %>
<th>Модератор</th>
<% end %>
</tr>
</thead>
<tbody>
<tr>
<td><%= text_field_tag "client" %></td>
<td><%= text_field_tag "id", nil, size: 1 %></td>
<td></td>
<td><%= submit_tag "Выбрать" %><br><br><%= button_tag "Очистить" %></td>
<td><%= select_tag "tariff", options_for_select(["", "1. Вечер", "2. Весь день", "1001. ВЕЧЕР БЕСПЛАТНО", "1002. ДЕНЬ БЕСПЛАТНО"]), {} %></td>
<td></td>
<td></td>
<td></td>
<td><%= select_tag "status", options_for_select(["", "В обработке", "Исполняется", "Отклонена", "Выполнена"]), {} %></td>
<td></td>
</tr>
<%= render #messages %>
</tbody>
</table>
<% end %>
</div>
...
And now it works correctly.

Form_tag do not add check_box_tag value into parameters

I have Pieces model, which is store item's parts. When I need, I'm asking to users, check pieces is ok or nok with generated forms.
I am creating reports model to store the forms which I asked from users.
So, when I generate the forms check_box and and text_field works fine. But when I submit the form, I can't get check_box values as a parameter.
{"utf8"=>"✓",
"_method"=>"patch",
"authenticity_token"=>"5OmdXCDixwxru2yBtB3YmT3YF/ZqOByoAJ3J29TyJikxJdA+RXAvGjwu8MBIPlJCROFx4V7AUcA7IIqIgthD9g==",
"notes"=>{"79"=>"asdasda","84"=>""},
"commit"=>"Submit",
"id"=>"5"}
here is my edit.html.erb
<%- model_class = Report -%>
<div class="page-header">
<h1><%=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human.titleize %></h1>
</div>
<% if #report.errors.any? %>
<div id="error_expl" class="panel panel-danger">
<div class="panel-heading">
<h3 class="panel-title"><%= pluralize(#report.errors.count, "error") %> prohibited this report from being saved:</h3>
</div>
<div class="panel-body">
<ul>
<% #report.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
</div>
<% end %>
<table class="table table-striped">
<thead>
<tr>
<th><%= model_class.human_attribute_name(:status) %></th>
<th><%= model_class.human_attribute_name(:serial_no) %></th>
<th><%= model_class.human_attribute_name(:category) %></th>
<th><%= model_class.human_attribute_name(:name) %></th>
<th><%= model_class.human_attribute_name(:brand) %></th>
<th><%= model_class.human_attribute_name(:model) %></th>
<th><%= model_class.human_attribute_name(:quantity) %></th>
</tr>
</thead>
<tbody>
<%= form_tag(report_path(#report), :method => :patch) do %>
<% #pieces.each do |piece| %>
<tr>
<td><div class="form-group">
<%= check_box_tag(:status, name: "status["+piece.id.to_s+"]", class: 'form-control') %>
</div></td>
<td><%= piece.try(:serial_no) %></td>
<td><%= piece.item.category.name %></td>
<td><%= piece.item.name %></td>
<td><%= piece.item.brand %></td>
<td><%= piece.item.model %></td>
<% if piece.serial_no.start_with?("D") %>
<td><%= piece.item.pieces.count %> <%= piece.item.unit.name %></td>
<% else %>
<td><%= piece.item.pieces.sum(:quantity) %> <%= piece.item.unit.name %></td>
<% end %>
</tr>
<tr>
<td colspan=7 class="hidden" id="hebele">
<%= text_field_tag(:note,"", placeholder: "Note ", name: "notes["+piece.id.to_s+"]",class: "form-control ") %>
</td>
</tr>
<% end %>
</tbody>
</table>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<%= submit_tag("Submit",:class => 'btn btn-primary') %>
<%= link_to t('.cancel', :default => t("helpers.links.cancel")), reports_path, :class => 'btn btn-default' %>
</div>
</div>
<% end %>
<script type="text/javascript">
$("[id='status']").bootstrapSwitch({
size: 'mini',
onColor: 'success',
offColor: 'danger',
indeterminate: true,
onSwitchChange: function(event, state) {
if (state == false){
$("#hebele").removeClass('hidden');
}else if(state == true){
$("#hebele").addClass('hidden');
}
}
});
</script>
controller:
def edit
#pieces = #report.pieces.joins(:item).group(:item_id)
#report = Report.find(params[:id])
end
You need to define the value of the check_box_tag:
<%= check_box_tag :status, piece.id, class: 'form-control' %>
If you're editing a #report, you'll be best using form_for:
<table>
<tbody>
<%= form_for #report do |f| %>
<% #pieces.each do |piece| %>
<tr>
<td>
<div class="form-group">
<%= f.check_box :status, class: 'form-control', price.id %>
</div>
</td>
<td><%= piece.try(:serial_no) %></td>
<td><%= piece.item.category.name %></td>
<td><%= piece.item.name %></td>
<td><%= piece.item.brand %></td>
<td><%= piece.item.model %></td>
<% if piece.serial_no.start_with?("D") %>
<td><%= piece.item.pieces.count %> <%= piece.item.unit.name %></td>
<% else %>
<td><%= piece.item.pieces.sum(:quantity) %> <%= piece.item.unit.name %></td>
<% end %>
</tr>
<tr>
<td colspan=7 class="hidden" id="hebele">
<%= f.text_field :note, placeholder: "Note", class: "form-control" %>
</td>
</tr>
<% end %>
<tr><td colspan="7"><%= f.submit, class: "btn btn-primary" %></td></tr>
<% end %>
</tbody>
</table>

How to check if association exists and display associated record instead of actual record.

I am trying to have the system check to see if there is a customer category, if there is, display the customer category and if not display the internal category. I tried doing something like
<% if c.customer_labor_category != 'nil' %>
I also tried the following right above where it displays "l"
<% if c.customer_labor_category.any? %>
I basically need it to check if there is a customer category if there is, use that field instead of the internal one.
<% c = lh.pluck('categories.category').uniq %>
<% if c.length == 0 %>
<tr>
<td class="tg-multirow" rowspan="1">Category</td>
<td class="tg-datacell"></td>
<td class="tg-celltitle" rowspan="1">Effort</td>
<td class="tg-datacell"></td>
</tr>
<% else %>
<% c.each do |l| %>
<tr>
<% if l == c.first %>
<td class="tg-celltitle" rowspan="<%= lc.length %>">Labor Category</td>
<% end %>
<td class="tg-datacell"> <%= l %> </td>
<% if l == c.first %>
<td class="tg-celltitle" rowspan="<%= c.length %>">effort</td>
<% end %>
<% hours = lh.joins(:category).where(:categories => { :category => l }).each.sum(&:hours) %>
<td class="tg-datacell"> <%= hours %></td>
</tr>
<% end %>
<% end %>
c.customer_labor_category.nil? # true if nil
c.customer_labor_category.present? # true if not nil

Random selection from Rails database works on Index, not on its 'Generator page'

I'm writing what's currently a very basic program (and I'm sure very badly-coded, though kinda working) to generate fitness plans, currently split by bodypart or through a generator that selects an item from each bodypart.
I'm having problems with the workout generator though - it works on the index page for testing purposes, with a new workout every time it's refreshed, though on the '/exercises/generator' page where it should live, it will load the index's random workout but not a new plan when refreshed. Looking for a solution to get it working as a standalone generator on this page.
I'm new to this, and have worked to get the program running with what I'm sure is very messy scope and code I'd love to get dryer, so bonus points for tips on correcting this!
If any of the above is unclear, let me know - here's the relevant code from the controller, index.html.erb and bodypart.html.erb (where the generator will sit), along with a partial sitting on the view pages. If there's anything else that would help - shout me.
Controller (less the standard CRUD info)
class ExercisesController < ApplicationController
private
def exercise_params
params.require(:exercise).permit(:move, :bodypart)
end
public
attr_accessor :move, :bodypart
def index
#exercise = Exercise.new
#exercises = Exercise.all
$gen = Exercise.pluck(:move, :bodypart)
$gen.shuffle!
$generatorl = $gen.select { |a, b| b == "legs" } #feel b.downcase should work to grab capitalized :bodyparts, though not working for now
$generatorl = $generatorl.first
$generatorb = $gen.select { |a, b| b == "back" }
$generatorb = $generatorb.first
$generators = $gen.select { |a, b| b == "stomach" }
$generators = $generators.first
$generatorsh = $gen.select { |a, b| b == "shoulders" }
$generatorsh = $generatorsh.first
$generatorc = $gen.select { |a, b| b == "chest" }
$generatorc = $generatorc.first
$generator = $generatorl, $generatorb, $generators, $generatorsh, $generatorc
$generator.shuffle!
end
def bodypart
#fullpath = request.fullpath
bp = if #fullpath == '/exercises/legs'
'legs'
elsif #fullpath == '/exercises/full'
'full'
elsif #fullpath =='/exercises/shoulders'
'shoulders'
elsif #fullpath == '/exercises/back'
'back'
elsif #fullpath == '/exercises/chest'
'chest'
elsif #fullpath == '/exercises/stomach'
'stomach'
elsif #fullpath == '/exercises/generator'
'generator'
else
'error'
end
#exercises = if bp == 'error'
redirect_to exercises_path
else
Exercise.where(:bodypart => bp)
end
end
(Definitely got the right amount of 'ends' in the real code, in case I've misquoted here)
And the views:
Index
<h1>Exercises</h1>
<p></p>
<%= render 'table' %>
<h2> Workout Generator </h2>
<p> <%= $gen.inspect %> </p>
<p> <%= $generator.inspect %> </p>
<p> <%= $generatorl.inspect %> </p>
<table border="1">
<tr>
<th><%= "Exercise" %></th>
<th><%= "Body part" %></th>
</tr>
<% $generator.each do |mv, bp| %>
<tr>
<td> <%= mv.titleize %> </td>
<td><i> <%= bp.titleize %> </i></td>
</tr>
<% end %>
</table>
The view for each bodypart / the generator:
<h1>
<% if #fullpath == '/exercises/generator' %>
<%= 'Generator' %>
<% else %>
<%= :bodypart.to_s.titleize %></h1>
<% end %>
<h2> Test <%= $fullpath.inspect %> <%= request.fullpath %> </h2>
<% if #exercises.empty? %>
<p> <%= $gen %> </p>
<p> <%= $generator %> </p>
<table border="1">
<tr>
<th><%= "Exercise" %></th>
<th><%= "Body part" %></th>
</tr>
<% $generator.each do |mv, bp| %>
<tr>
<td> <%= mv.titleize %> </td>
<td><i> <%= bp.titleize %> </i></td>
</tr>
<% end %>
</table>
<% else %>
<%= render 'table' %>
<table>
<tr>
<td> <%= #exercises.inspect %> </td>
</tr>
</table>
<% end %>
And finally the partial for Table:
<table border="1">
<tr>
<th><%= "Exercise" %></th>
<th><%= "Body part" %></th>
</tr>
<% for exercise in #exercises %>
<tr id="exercise_<%= exercise.id %>">
<td> <%= exercise.move.titleize %> </td>
<td><i> <%= exercise.bodypart.titleize %> </i></td>
<td> <%= link_to "Edit", edit_exercise_path(exercise) %> </td>
<td> <%= button_to 'Delete', exercise, :method => :delete %> </td>
</tr>
<% end %>
</table>
Thanks so much in advance - if I'm being unclear or any other code would be useful, let me know!

Resources