Skip to content

Instantly share code, notes, and snippets.

@biographie
Created July 28, 2013 17:57
Show Gist options
  • Save biographie/6099459 to your computer and use it in GitHub Desktop.
Save biographie/6099459 to your computer and use it in GitHub Desktop.
<% for task in current_task %>
<% if task.due_date.to_date == DateTime.now.to_date %>
<strong>Today</strong>
<%= task.description %>
<% elsif task.due_date.to_date == (DateTime.now + 1.day).to_date %>
<strong>Tomorrow</strong>
<%= task.description %>
<% end %>
<% end %>
class CompaniesController < ApplicationController
def index
@companies = Company.paginate(page: params[:page], :per_page =>10)
@company = Company.new
@company.phone_numbers.build
@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])
@tasks = @company.tasks
@contact= Contact.new
end
def create
@company = Company.create(params[:company])
@companies = Company.paginate(page: params[:page])
respond_to do |format|
if @company.save
format.html { render action: "index" }
format.js
format.json { }
else
render :json => { }, status => 500
end
end
end
def edit
@company = Company.find(params[:id])
end
end
# == Schema Information
#
# Table name: companies
#
# id :integer not null, primary key
# name :text
# email :text
# address :text
# background :text
# logo :text
# created_at :datetime not null
# updated_at :datetime not null
# user_id :integer
#
class Company < ActiveRecord::Base
attr_accessible :address, :background, :email, :logo, :name, :phone_numbers_attributes, :contacts
has_many :deals
has_many :tasks
has_many :activities
belongs_to :users
has_many :phone_numbers
has_many :contacts
accepts_nested_attributes_for :phone_numbers
end
<div class="content pull-left">
<h2><%= @company.name %></h2>
<%= link_to "edit company", edit_company_path %>
<div class="margin-bottom">
<% for phone in @company.phone_numbers %>
<li><%= phone.number %> (<%= phone.place %>)</li>
<% end %>
</div>
<ul class="nav nav-tabs margin-top">
<li class="active">
<a href="#">Contacts</a>
</li>
<li> <%= link_to Deal, new_company_deal_path(@company)%></li>
<li><a href="#">Activities</a></li>
</ul>
<div>
<button class="btn btn-small btn-info" type="button">Select All</button>
<button class="btn btn-small btn-info" type="button">Delete</button>
<%= link_to "Add a person to this company", href="#new-contact-form", :class=>"pull-right inline"%>
</div>
<div class="x">
<% for contact in @company.contacts %>
<div class="contact-card">
<ul>
<%= link_to(company_contact_path(@company,contact)) 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>
<% end %>
</ul>
</div>
<%= cycle('','<div class="clearfix"></div>'.html_safe, :name=>"clearfix") %>
<% end %>
</div>
<div class="hide">
<div id="new-contact-form">
<%= render :partial => "contacts/newcontactform", :locals => {:contact => Contact.new} %>
</div>
</div>
</div>
<div class="sidebar pull-right">
<div class="well sidebar-width margin-right">
<%= link_to "Add a task", new_company_task_path(@company) %>
<%= render "tasks/tasklist", :current_task=>@tasks %>
</div>
</div>
<div class="clearfix"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment