Instead of each table being created as a new row like:
TABLE #1
TABLE #2
TABLE #3
How can I make it like so:
TABLE #1 | TABLE #2 | TABLE #3
I'm asking specifically in regards to the Monthly Average table.
Any help would be greatly appreciated!
class Quantified < ActiveRecord::Base
belongs_to :user
scope :averaged, -> { where(categories: 'Monthly Average') }
scope :instance, -> { where(categories: 'One-Time Instance') }
CATEGORIES = ['Monthly Average', 'One-Time Instance']
end
controller
def index
@averaged_quantifieds = current_user.quantifieds.averaged
@instance_quantifieds = current_user.quantifieds.instance
end
index
<!-- Default bootstrap panel contents -->
<div id="values" class="panel panel-default">
<div class="panel-heading"><h4><b>AVERAGE</b></h4></div>
<!-- Table -->
<table>
<thead>
<% @averaged_quantifieds.each do |averaged| %>
<% if averaged.user == current_user %>
<tr>
<td>
<th class="value">
<%= averaged.name %>
(<%= averaged.metric %>)
</th>
</tr>
</thead>
<tbody>
<tr>
<th class="category">
<%= averaged.date.strftime("%m-%d-%Y") %>
</th>
<th class="value">
<%= averaged.result %>
</th>
</tr>
</tbody>
</td>
<% end %>
<% end %>
</table>
</div>
form
<%= form_for(@quantified) do |f| %>
<% if @quantified.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@quantified.errors.count, "error") %> prohibited this quantified from being saved:</h2>
<ul>
<% @quantified.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="america">
<form>
<%= f.select :categories, Quantified::CATEGORIES %>
<br>
<br>
<div class="form-group">
<%= f.text_field :name, class: 'form-control', placeholder: 'Enter Name' %>
</div>
<div class="form-group">
<%= f.text_field :result, class: 'form-control', placeholder: 'Enter Result' %>
</div>
<div class="form-group">
<%= f.text_field :metric, class: 'form-control', placeholder: 'Enter Metric' %>
</div>
<div class="date-group">
<label> Date: </label>
<%= f.date_select :date, :order => [:month, :day, :year], class: 'date-select' %>
</div>
<div class="america2">
<%= button_tag(type: 'submit', class: "btn") do %>
<span class="glyphicon glyphicon-plus"></span>
<% end %>
<%= link_to quantifieds_path, class: 'btn' do %>
<span class="glyphicon glyphicon-chevron-left"></span>
<% end %>
<%= link_to @quantified, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn' do %>
<span class="glyphicon glyphicon-trash"></span>
<% end %>
</div>
</form>
</div>
<% end %>
schema
create_table "quantifieds", force: true do |t|
t.string "categories"
t.string "name"
t.string "metric"
t.decimal "result"
t.date "date"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id"
end
add_index "quantifieds", ["categories"], name: "index_quantifieds_on_categories"
add_index "quantifieds", ["user_id"], name: "index_quantifieds_on_user_id"