Created
July 22, 2013 07:28
-
-
Save biographie/6051926 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% 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