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 Rating < ActiveRecord::Base | |
belongs_to :thing, :polymorphic => true | |
end | |
class Comment < ActiveRecord::Base | |
has_many :ratings | |
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
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 |
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
## /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 |
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
{ :one => "Weee", :two => { :three => "" }, :four => "" }.delete_if { |k,v| v.class == Hash ? v.delete_if { |k2,v2| v2.blank? } : v.blank? } |
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 color in colors %> | |
<%= color %> | |
<% 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
class Waging < ActiveRecord::Base | |
has_many :employees | |
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
Clone the repository using: | |
git clone git://github.com/Radar/rboard.git | |
All the code is there, I promise you. | |
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
# Add this line: | |
map.resources :teams |
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 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) |
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 Date | |
def to_words | |
today = Date.today | |
case self | |
when today | |
"Today" | |
when today - 1 | |
"Yesterday" | |
when today + 1 |
OlderNewer