Skip to content

Instantly share code, notes, and snippets.

class Post < ActiveRecord::Base
belongs_to :user
before_save :default_values
def default_values
self.cached_votes_total ||= 1
end
acts_as_votable
end
Started GET "/assets/companies.js?body=1" for 127.0.0.1 at 2013-07-29 17:47:00 +0300
Served asset /companies.js - 304 Not Modified (0ms)
Started GET "/assets/contacts.js?body=1" for 127.0.0.1 at 2013-07-29 17:47:00 +0300
Served asset /contacts.js - 304 Not Modified (0ms)
Started GET "/assets/colorbox-rails/jquery.colorbox-min.js?body=1" for 127.0.0.1 at 2013-07-29 17:47:00 +0300
Served asset /colorbox-rails/jquery.colorbox-min.js - 304 Not Modified (0ms)
@biographie
biographie / _add_task.html.erb
Last active December 20, 2015 08:59
error in console: Uncaught TypeError: Accessing selectionDirection on an input element that cannot have a selection. application.js?body=1:51 Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://localhost:3000/companies/5/tasks
<div class="add-task arrow_box hide">
<%= form_for ([@company, @task]), :remote => true do |f| %>
<%= f.label :description %>
<%= f.text_field :description, :class => "input-width bottom-border" %>
<%= f.label :task_category_id, "Choose a category" %>
<%= f.collection_select(:task_category_id, TaskCategory.all, :id, :task_category) %>
<%= f.label :due_date %>
<%= f.select :due_date_word, ['Today', 'Tomorrow', 'Next Week']%>
# == Schema Information
#
# Table name: tasks
#
# id :integer not null, primary key
# title :text
# task_category_id :integer
# due_date :datetime
# description :text
# completed_at :datetime
2.0.0p195 :027 > Task.last
Task Load (0.4ms) SELECT "tasks".* FROM "tasks" ORDER BY "tasks"."id" DESC LIMIT 1
=> #<Task id: 13, title: nil, task_category_id: nil, due_date: "2013-07-28 18:11:00", description: "Hello", completed_at: nil, company_id: 5, contact_id: 0, user_id: nil, created_at: "2013-07-28 18:11:00", updated_at: "2013-07-28 18:11:00">
2.0.0p195 :028 > Task.where(due_date: Date.today)
Task Load (0.4ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."due_date" = '2013-07-28'
=> []
2.0.0p195 :029 >
<% 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 %>
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
@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
# == Schema Information
#
# Table name: contacts
#
# id :integer not null, primary key
# first_name :text
# last_name :text
# email :text
# bcard :text
# linked_in :text