Skip to content

Instantly share code, notes, and snippets.

@biographie
Created July 22, 2013 07:28
Show Gist options
  • Save biographie/6051926 to your computer and use it in GitHub Desktop.
Save biographie/6051926 to your computer and use it in GitHub Desktop.
class CompaniesController < ApplicationController
def index
@companies = Company.paginate(page: params[:page])
@due_today = Task.where(:due_date => Time.now.beginning_of_day..Time.now.end_of_day)
# @disable_nav = true to stop a partial from displaying in a certain page using unless in application.html.erb
end
def new
@company = Company.new
@company.phone_numbers.build
end
def show
@company = Company.find(params[:id])
end
def create
@company = Company.create(params[:company])
if @company.save
redirect_to "/companies"
else
render 'new'
end
end
def edit
@company = Company.find(params[:id])
end
end
<% for contact in @company.contacts %>
<div class="<%= cycle('pull-left', 'pull-right') %>">
<div class="contact-card">
<ul>
<%= link_to(contact_path) do %>
<li><%= contact.first_name %> <%= contact.last_name %></li>
<% end %>
<li><%= contact.email %></li>
<% for phone in contact.phone_numbers %>
<li><%= phone.number %> (<%= phone.place %>)</li>
</ul>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment