Skip to content

Instantly share code, notes, and snippets.

def using_open_id?
!identity_url.blank?
end
validates_presence_of :identity_url, :if => using_open_id?
validates_presence_of :username, :unless => using_open_id?
validates_presence_of :password, :unless => using_open_id?
Raise error when trying to add to a has_many :through association. •
Use the Join Model instead. [Rick]
@post.tags << @tag # BAD
@post.taggings.create(:tag => @tag) # GOOD
class Account < ActiveRecord::Base
validates_uniqueness_of :email,:case_sensitive => false
end
Allow multiple association extensions with :extend option (closes • #4666) [Josh Susser]
class Account < ActiveRecord::Base
has_many :people, :extend => [FindOrCreateByNameExtension, FindRecentExtension]
end
#Added Array#rand #9170 [norbert]. Examples:•
[].rand # => nil
['a'].rand # => 'a'
[1,2,3].rand # => 1 or 2 or 3
class Course < ActiveRecord::Base
has_many :rounds, :include => :scores
has_many :holes do
def method_missing(method)
find(
:first,
:conditions => { :hole_number => method.to_s.send(:gsub, /[a-z|A-Z|_]/, "").to_i }
)
end
end
def get_vehicle_report(vehicle_id)
vehicle = Vehicle.find(vehicle_id)
returning Report.new(vehicle_id, vehicle.year, vehicle.description) do |report|
if report.something.nil?
owner = vehicle.owner
# ...
end
end
end
$ ruby script/console
>> app.url_for :controller => :public, :action => :about
=> "http://example.com/public/about"
>> app.get("/public")
=> 200
>> app.get("/ryan")
=> 404
# others include
You'll also need a controller to send the photo data when the image is requested by a web browser. This can be done all in one action with respond_to and an extra mime type. In environment.rb, declare the types of the images that you will be serving.
Mime::Type.register "image/jpeg", :jpg
Mime::Type.register "image/png", :png
def show
@photo = Photo.find params[:id]
respond_to do |format|
http://gnn.gamer.com.tw/4/43094.html
 進入日美歐等海外遊戲大廠參與世界級遊戲的開發製作,一直以來都是許多有志從事遊戲創作者心目中夢寐以求的目標,不過遠赴海外不論在語言或生活習慣上都存在著相當大的差異與衝擊,參與行銷全球之世界級遊戲製作對個人專業實力更是一大考驗,種種的挑戰往往令人為之卻步。
  在本次的專題中,巴哈姆特 GNN 特別訪問到自 2004 年起加入美國索尼電腦娛樂(SCEA)聖塔摩尼卡工作室(Santa Monica Studio),一路參與《戰神(God of War)》系列 1~3 代製作的台灣遊戲創作者路致遠(Louis Lu),分享他投入遊戲創作的經歷,遠赴海外參與世界級遊戲創作的經驗,以及對於台灣與美國遊戲創作環境差異的感想。
GNN 提問以下簡稱「Q」 路致遠以下簡稱「路」 GNN 編輯以下簡稱「G」
Q:能否請您簡單作一自我介紹?
路:業界的朋友叫我 Louis 的比較多,我是台北人,國立台灣藝術大學美術系畢業。