Skip to content

Instantly share code, notes, and snippets.

<h1>Add New Company</h1>
<%= form_for(@company) do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :address %>
<%= f.text_field :address %>
<%= f.nested_fields_for :phone_numbers do |f|
render 'phone', f: f
class TasksController < ApplicationController
def index
end
def show
end
def new
resources :companies do
resource :tasks
resources :contacts do
end
end
resources :companies do
resource :tasks
resources :contacts do
end
end
resources :contacts do
resources :tasks
end
# == Schema Information
#
# Table name: contacts
#
# id :integer not null, primary key
# first_name :text
# last_name :text
# email :text
# bcard :text
# linked_in :text
@biographie
biographie / company_controller.rb
Created July 21, 2013 17:27
ActiveRecord::RecordNotFound in CompaniesController#edit Couldn't find Company without an ID
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
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
<% 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 %>
<% 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 %>