顯示具有 with_options 標籤的文章。 顯示所有文章
顯示具有 with_options 標籤的文章。 顯示所有文章

2008年11月18日 星期二

with_scope and with_options

with_scope 和 with_options的用法

2008年11月10日 星期一

with_options

http://railscasts.com/episodes/42-with-options

map.with_options :controller => 'membercenter' do |t|
t.partner_login 'membercenter/plogin', :action => 'partner_login'
t.partner_signup 'membercenter/psignup', :action => 'partner_signup'
t.partner_logout 'membercenter/plogout', :action => 'partner_logout'
t.default 'membercenter/:action'
end


def index
FaqCommon.with_options :order => "created_at DESC", :limit => 9 do |faqcommon|
@member_faqs = faqcommon.find(:all, :conditions => ["title_type = ?", 0] )
@use_faqs = faqcommon.find(:all, :conditions => ["title_type = ?", 1] )
end
end

2008年5月8日 星期四

routes with_options

http://api.rubyonrails.org/classes/ActionController/Routing.html
http://ihower.idv.tw/blog/
http://weblog.jamisbuck.org/2007/1/24/object-with_options

#Object#with_options

最常用在 routes.rb,不過其實任意物件都可以用,他會將參數自動 merge 到 method call 的 hash 參數:

map.with_options( :controller => "people" ) do |p|
p.root :action => "index"
p.about :action => "about"
end


這樣替route 取名root , about
rails 替我們提供了url, path

root_url 可以替我們建出full path

root_path 建出的是URI path ( 沒包含host 的部份)

redirect_to root_path