Skip to content

Instantly share code, notes, and snippets.

View radar's full-sized avatar

Ryan Bigg radar

View GitHub Profile
class Rating < ActiveRecord::Base
belongs_to :thing, :polymorphic => true
end
class Comment < ActiveRecord::Base
has_many :ratings
end
class AddPriceToProduct < ActiveRecord::Migration
def self.up
add_column :products, :price, :decimal,
:precision => 8, :scale => 2, :default => 0
end
def self.down
remove_column :products, :price
end
end
## /users/edit.html.erb
<% form_for [:cp, @user], :url => { :action => 'update', :id => @user.id } do |f| %>
...
<%= collection_select :users, :show_id, Show.find(:all), :id, :name, { :prompt => true } %>
## users_controller.rb
@user.shows << Show.find(params[:users][:show_id])
## error
ActiveRecord::AssociationTypeMismatch in Cp/usersController#update
{ :one => "Weee", :two => { :three => "" }, :four => "" }.delete_if { |k,v| v.class == Hash ? v.delete_if { |k2,v2| v2.blank? } : v.blank? }
<% for color in colors %>
<%= color %>
<% end %>
class Waging < ActiveRecord::Base
has_many :employees
end
Clone the repository using:
git clone git://github.com/Radar/rboard.git
All the code is there, I promise you.
# Add this line:
map.resources :teams
class Date
def to_words
if self == Date.today
"Today"
elsif self <= Date.today - 1
if self == Date.today - 1
"Yesterday"
elsif ((Date.today - 7)..(Date.today - 1)).include?(self)
"Last #{self.strftime("%A")}"
elsif ((Date.today - 14)..(Date.today - 8)).include?(self)
class Date
def to_words
today = Date.today
case self
when today
"Today"
when today - 1
"Yesterday"
when today + 1