锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久综合一区二区无码,久久久久人妻精品一区,日本久久久精品中文字幕http://m.shnenglu.com/cpunion/category/88.htmlAS/C/C++/D/Java/JS/Python/Rubyzh-cnMon, 19 May 2008 12:34:08 GMTMon, 19 May 2008 12:34:08 GMT60[RoR] Post/Get鍒嗘淳http://m.shnenglu.com/cpunion/archive/2006/09/17/12571.htmlqieziqieziSun, 17 Sep 2006 03:13:00 GMThttp://m.shnenglu.com/cpunion/archive/2006/09/17/12571.htmlhttp://m.shnenglu.com/cpunion/comments/12571.htmlhttp://m.shnenglu.com/cpunion/archive/2006/09/17/12571.html#Feedback1http://m.shnenglu.com/cpunion/comments/commentRss/12571.htmlhttp://m.shnenglu.com/cpunion/services/trackbacks/12571.html涓銆佸墠璦

鍑轟簬鏁版嵁瀹夊叏鎬ц冭檻錛屾煇浜涚牬鍧忔ч摼鎺ュ簲璇ヤ嬌鐢╬ost璇鋒眰錛屾瘮濡備竴涓垹闄よ褰曠殑璇鋒眰銆?br />
闄や簡(jiǎn)鑴氭湰紜浠ュ錛屾湇鍔$榪橀渶瑕乸ost楠岃瘉錛屽洜涓鴻剼鏈槸鍙互緇曡繃鐨勩傛兂鍍忎綘鐨勯〉闈笂鏈変竴涓垹闄ら摼鎺ワ紝鍙綔浜?jiǎn)瀹㈡堬L(fēng)鑴氭湰紜錛堣佺殑scaffold鐢熸垚浠g爜鏈夎繖闂錛夛紝琚玤oogle鎵懼埌浜?jiǎn)锛屽畠涓涓姹傚氨浼?xì)璁╀綘鐨勬暟鎹涪澶便?br />
rails瀵逛簬榪欑被璇鋒眰鐨勫鐞嗭紝鏄氳繃verify鏂規(guī)硶錛岄粯璁ょ殑scaffold鐢熸垚浠g爜鏈夊涓嬪唴瀹癸細(xì)

聽(tīng)聽(tīng)#聽(tīng)GETs聽(tīng)should聽(tīng)be聽(tīng)safe聽(tīng)(see聽(tīng)http://www.w3.org/2001/tag/doc/whenToUseGet.html)
聽(tīng)聽(tīng)verify聽(tīng):method聽(tīng)=>聽(tīng):post,聽(tīng):only聽(tīng)=>聽(tīng)[聽(tīng):destroy,聽(tīng):create,聽(tīng):update聽(tīng)],
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
:redirect_to聽(tīng)=>聽(tīng){聽(tīng):action聽(tīng)=>聽(tīng):list聽(tīng)}

鍙湁post璇鋒眰鏃訛紝destroy鎵嶄細(xì)琚厑璁革紝濡傛灉鏄痝et錛屽氨浼?xì)琚噸瀹氬悜鍒發(fā)ist銆?br />
浜屻佸疄鐜?/b>

鎴戣嚜宸卞疄鐜頒簡(jiǎn)涓涓猰ethod_dispatch錛屽綋璇鋒眰涓涓?test/a鏃訛紝濡傛灉鏄痝et錛屽垯浼?xì)鐩存帴鎵цTestController#a錛涘鏋滄槸post錛屽垯浼?xì)鎵цTestController#a_post錛宎_post搴旇鏄痯rotected錛岃繖鏍蜂笉浼?xì)鐩存帴鏆撮湶缁欏鎴峰Q実et/post灝變弗鏍煎尯鍒嗗紑鏉ヤ簡(jiǎn)銆?br />
method_dispatch鐜板湪鏄洿鎺ュ疄鐜板湪ApplicationController涓殑錛屼唬鐮佸涓嬶細(xì)

class聽(tīng)ApplicationController聽(tīng)<聽(tīng)ActionController::Base
聽(tīng)聽(tīng)protected
聽(tīng)聽(tīng)def聽(tīng)self
.method_dispatch(*methods)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)before_filter聽(tīng)
:do_method_dispatch,聽(tīng):only聽(tīng)=>聽(tīng)methods.flatten.map(&:to_sym)
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)private
聽(tīng)聽(tīng)def聽(tīng)do_method_dispatch
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
if聽(tīng)request.post?聽(tīng)&&聽(tīng)respond_to?("#{action_name}_post")
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
eval("#{action_name}_post")
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
return聽(tīng)false
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)end
end

鐢變簬ApplicationController閲岄潰鐨勬柟娉曚細(xì)琚瓙綾葷戶鎵垮埌錛屾墍浠ュ繀欏諱弗鏍煎鐞嗚闂駭鍒?br />
浣跨敤濡備笅錛?br />
class聽(tīng)TestController聽(tīng)<聽(tīng)ApplicationController
聽(tīng)聽(tīng)method_dispatch聽(tīng)
:a

聽(tīng)聽(tīng)def聽(tīng)
index
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)a
聽(tīng)聽(tīng)聽(tīng)聽(tīng)render聽(tīng)
:text聽(tīng)=>聽(tīng)'get聽(tīng)a'
聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)def聽(tīng)b
聽(tīng)聽(tīng)聽(tīng)聽(tīng)render聽(tīng)
:text聽(tīng)=>聽(tīng)'get聽(tīng)b'
聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)protected
聽(tīng)聽(tīng)def聽(tīng)a_post
聽(tīng)聽(tīng)聽(tīng)聽(tīng)render聽(tīng)
:text聽(tīng)=>聽(tīng)'post聽(tīng)a'
聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)def聽(tīng)b_post
聽(tīng)聽(tīng)聽(tīng)聽(tīng)render聽(tīng)
:text聽(tīng)=>聽(tīng)'post聽(tīng)b'
聽(tīng)聽(tīng)end
end

娉ㄦ剰a_post錛宐_post瑕佽淇濇姢璧鋒潵闃叉鐩存帴璋冪敤銆?br />
index.rhtml閲岄潰婕旂ず浜?jiǎn)鋴社敤get鍜宲ost鐨勬儏鍐碉細(xì)

<%=聽(tīng)link_to聽(tīng)"Get聽(tīng)a",聽(tīng):action聽(tīng)=>聽(tīng)'a'聽(tīng)%>
<%=聽(tīng)link_to聽(tīng)"Post聽(tīng)a",聽(tīng){:action聽(tīng)=>聽(tīng)'a'},聽(tīng){:post聽(tīng)=>聽(tīng)true}聽(tīng)%><br聽(tīng)/>

<%=聽(tīng)link_to聽(tīng)"Get聽(tīng)b",聽(tīng):action聽(tīng)=>聽(tīng)'b'聽(tīng)%>
<%=聽(tīng)link_to聽(tīng)"Post聽(tīng)b",聽(tīng){:action聽(tīng)=>聽(tīng)'b'},聽(tīng){:post聽(tīng)=>聽(tīng)true}聽(tīng)%><br聽(tīng)/>

rails鍦ㄥ鐞嗘湁:post => true鍙傛暟鐨刲ink_to鏃訛紝鐢熸垚鐨勪唬鐮佸涓嬶細(xì)

<a聽(tīng)href="/test/a"聽(tīng)onclick="var聽(tīng)f聽(tīng)=聽(tīng)document.createElement('form');
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) this.parentNode.appendChild(f);聽(tīng)f.method聽(tīng)=聽(tīng)'POST';聽(tīng)f.action聽(tīng)=聽(tīng)this.href;聽(tīng)f.submit();return聽(tīng)false;"
>Post聽(tīng)a</a>

緇忔祴璇曚笂闈唬鐮佸伐浣滄儏鍐佃壇濂斤紝浣跨敤get璁塊棶/test/a鏃訛紝鏄劇ずget a錛涗嬌鐢╬ost璁塊棶鏃訛紝鏄劇ずpost a銆備嬌鐢╣et璁塊棶/test/b鏃訛紝鏄劇ずget b錛涗嬌鐢╬ost鏃訛紝鏄劇ずget b錛屽洜涓篵騫舵病鏈変嬌鐢╩ethod_dispatch銆?br />
涓夈佸簲鐢?/b>

涓嬮潰鐨刾osts_controller.rb鏄痵caffold鐢熸垚鐨勶細(xì)

class聽(tīng)PostsController聽(tīng)<聽(tīng)ApplicationController
聽(tīng)聽(tīng)def聽(tīng)
index
聽(tīng)聽(tīng)聽(tīng)聽(tīng)list
聽(tīng)聽(tīng)聽(tīng)聽(tīng)render聽(tīng)
:action聽(tīng)=>聽(tīng)'list'
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)
#聽(tīng)GETs聽(tīng)should聽(tīng)be聽(tīng)safe聽(tīng)(see聽(tīng)http://www.w3.org/2001/tag/doc/whenToUseGet.html)
聽(tīng)聽(tīng)verify聽(tīng):method聽(tīng)=>聽(tīng):post,聽(tīng):only聽(tīng)=>聽(tīng)[聽(tīng):destroy,聽(tīng):create,聽(tīng):update聽(tīng)],
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
:redirect_to聽(tīng)=>聽(tīng){聽(tīng):action聽(tīng)=>聽(tīng):list聽(tīng)}

聽(tīng)聽(tīng)def聽(tīng)list
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@post_pages,聽(tīng)@posts聽(tīng)=聽(tīng)paginate聽(tīng):posts,聽(tīng):per_page聽(tīng)=>聽(tīng)10
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)show
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@post聽(tīng)=聽(tīng)Post.find(params[:id])
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)new
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@post聽(tīng)=聽(tīng)Post.new
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)create
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@post聽(tīng)=聽(tīng)Post.new(params[:post])
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
if聽(tīng)@post.save
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)flash[
:notice]聽(tīng)=聽(tīng)'Post聽(tīng)was聽(tīng)successfully聽(tīng)created.'
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)redirect_to聽(tīng)
:action聽(tīng)=>聽(tīng)'list'
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
else
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)render聽(tīng)
:action聽(tīng)=>聽(tīng)'new'
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)edit
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@post聽(tīng)=聽(tīng)Post.find(params[:id])
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)update
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@post聽(tīng)=聽(tīng)Post.find(params[:id])
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
if聽(tīng)@post.update_attributes(params[:post])
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)flash[
:notice]聽(tīng)=聽(tīng)'Post聽(tīng)was聽(tīng)successfully聽(tīng)updated.'
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)redirect_to聽(tīng)
:action聽(tīng)=>聽(tīng)'show',聽(tīng):id聽(tīng)=>聽(tīng)@post
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
else
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)render聽(tīng)
:action聽(tīng)=>聽(tīng)'edit'
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)destroy
聽(tīng)聽(tīng)聽(tīng)聽(tīng)Post
.find(params[:id]).destroy
聽(tīng)聽(tīng)聽(tīng)聽(tīng)redirect_to聽(tīng)
:action聽(tīng)=>聽(tīng)'list'
聽(tīng)聽(tīng)end
end

鍙互鐪嬪埌錛屽畠娣誨姞浜?jiǎn)verify錛屼絾action榪囧錛岄渶瑕佸湪verify涓淮鎶や竴浠藉搴旀柟娉曞悕錛岀◢涓嶇暀紲炲氨瀹規(guī)槗鍑虹幇婕忔礊銆?br />
鎴戞妸瀹冧慨鏀瑰涓嬶細(xì)

class聽(tīng)PostsController聽(tīng)<聽(tīng)ApplicationController
聽(tīng)聽(tīng)method_dispatch聽(tīng)
:new,聽(tīng):edit,聽(tīng):destroy

聽(tīng)聽(tīng)def聽(tīng)
index
聽(tīng)聽(tīng)聽(tīng)聽(tīng)list
聽(tīng)聽(tīng)聽(tīng)聽(tīng)render聽(tīng)
:action聽(tīng)=>聽(tīng)'list'
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)list
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@post_pages,聽(tīng)@posts聽(tīng)=聽(tīng)paginate聽(tīng):posts,聽(tīng):per_page聽(tīng)=>聽(tīng)10
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)show
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@post聽(tīng)=聽(tīng)Post.find(params[:id])
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)new
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@post聽(tīng)=聽(tīng)Post.new
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)edit
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@post聽(tīng)=聽(tīng)Post.find(params[:id])
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)destroy
聽(tīng)聽(tīng)聽(tīng)聽(tīng)render聽(tīng)
:inline聽(tīng)=>聽(tīng)<<-EOS
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) Are you sure?
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
<%=聽(tīng)link_to聽(tīng)"Yes",聽(tīng){},聽(tīng):post聽(tīng)=>聽(tīng)true聽(tīng)%>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
<%=聽(tīng)link_to聽(tīng)"No",聽(tīng):action聽(tīng)=>聽(tīng)'edit', :id => params[:id]%>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)EOS
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)protected
聽(tīng)聽(tīng)def聽(tīng)destroy_post
聽(tīng)聽(tīng)聽(tīng)聽(tīng)Post
.find(params[:id]).destroy
聽(tīng)聽(tīng)聽(tīng)聽(tīng)redirect_to聽(tīng)
:action聽(tīng)=>聽(tīng)'list'
聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)def聽(tīng)edit_post
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@post聽(tīng)=聽(tīng)Post.find(params[:id])
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
if聽(tīng)@post.update_attributes(params[:post])
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)flash[
:notice]聽(tīng)=聽(tīng)'Post聽(tīng)was聽(tīng)successfully聽(tīng)updated.'
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)redirect_to聽(tīng)
:action聽(tīng)=>聽(tīng)'show',聽(tīng):id聽(tīng)=>聽(tīng)@post
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
else
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)render聽(tīng)
:action聽(tīng)=>聽(tīng)'edit'
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)def聽(tīng)new_post
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@post聽(tīng)=聽(tīng)Post.new(params[:post])
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
if聽(tīng)@post.save
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)flash[
:notice]聽(tīng)=聽(tīng)'Post聽(tīng)was聽(tīng)successfully聽(tīng)created.'
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)redirect_to聽(tīng)
:action聽(tīng)=>聽(tīng)'list'
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
else
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)render聽(tīng)
:action聽(tīng)=>聽(tīng)'new'
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)end
end

鐩稿簲鍦幫紝榪橀渶瑕佹妸new.rhtml涓殑action浠巆reate淇敼鍒皀ew錛屾妸edit.rhtml涓殑action浠巙pdate淇敼鍒癳dit銆?br />
榪欐牱鐨勪慨鏀規(guī)妸蹇呴』浣跨敤post璇鋒眰鐨刟ction闅愯棌璧鋒潵錛岃岀浉搴旂殑get鎿嶄綔鏄笉淇敼鎴栧垹闄よ褰曠殑錛屽鏋滀互post璇鋒眰錛屾墠浼?xì)鑷姩璋冪敤杩欎簺淇濇姢鐨勬栆?guī)硶銆?br />

qiezi 2006-09-17 11:13 鍙戣〃璇勮
]]>
[Ruby] Ruby AOPhttp://m.shnenglu.com/cpunion/archive/2006/09/16/12539.htmlqieziqieziSat, 16 Sep 2006 01:46:00 GMThttp://m.shnenglu.com/cpunion/archive/2006/09/16/12539.htmlhttp://m.shnenglu.com/cpunion/comments/12539.htmlhttp://m.shnenglu.com/cpunion/archive/2006/09/16/12539.html#Feedback1http://m.shnenglu.com/cpunion/comments/commentRss/12539.htmlhttp://m.shnenglu.com/cpunion/services/trackbacks/12539.html
鍦ㄥ叾瀹冭璦閲屽疄鐜癆OP鐨勭‘姣旇緝楹葷儲(chǔ)錛宩ava瑕佺敤鍒板姩鎬乸roxy錛屽鏋滄槸C錛嬶紜錛岄櫎浜?jiǎn)浠庢簮鐮佷笂淇敼杩樼湡娌″ソ鍔炴硶锛宎spectc灝辨槸榪欎箞鍋氱殑銆傞偅涔坮uby閲岄潰濡備綍瀹炵幇鍛紵

鐢變簬ruby鏄姩鎬佽剼鏈璦錛岃繍琛屾湡鍙互鎶婁竴涓柟娉曟敼鍚嶏紝涔熷彲浠ユ瀯閫犱竴涓瓧絎︿覆鍔ㄦ佺敓鎴愭柟娉曪紝閭d箞瀹炵幇榪欎釜灝變笉鏄毦浜嬩簡(jiǎn)銆?br />
module聽(tīng)ExecuteBefore
聽(tīng)聽(tīng)def聽(tīng)self
.included(base)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)base
.extend(ClassMethods)
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)module聽(tīng)ClassMethods
聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)execute_before(before_method
,聽(tīng)*methods)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)methods
.flatten.map(&:to_sym).each聽(tīng)do聽(tīng)|method|
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)alias_method聽(tīng)
"#{method}_old".to_sym,聽(tīng)method
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)class_eval聽(tīng)
<<-eval_end
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)
#{method}(*args)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)#{before_method}(*args)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)#{method}_old(*args)

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)eval_end
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)end
end

浣跨敤鏃跺彧闇瑕佸湪綾婚噷闈nclude榪欎釜妯″潡灝辮浜?jiǎn)锛岀浉褰撲簬mixin鐨勫姛鑳姐?br />
class聽(tīng)TestController聽(tīng)<聽(tīng)ApplicationController

聽(tīng)聽(tīng)def聽(tīng)
index
聽(tīng)聽(tīng)聽(tīng)聽(tīng)a(
1)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)b(
1,2)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)c(
1,2,3)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)render聽(tīng)
:text聽(tīng)=>聽(tīng)'hello'
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)protected
聽(tīng)聽(tīng)def聽(tīng)
log(*args)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)puts聽(tīng)
"log:聽(tīng)#{args.map(&:to_s).join(',聽(tīng)')}"
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)a(a)
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)b(a
,b)
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)c(a
,b,c)
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)include聽(tīng)ExecuteBefore
聽(tīng)聽(tīng)execute_before聽(tīng)
:log,聽(tīng):a,聽(tīng):b,聽(tīng):c
end

娉ㄦ剰錛岀敱浜庝嬌鐢╡xecute_before鏃跺悗闈㈠嚑涓柟娉曞繀欏昏鏈夊畾涔夛紝鎵浠ュ繀欏繪斁鍦ㄥ悗闈紝鍚﹀垯灝變細(xì)鍑洪敊銆?br />

qiezi 2006-09-16 09:46 鍙戣〃璇勮
]]>
[RoR] Rails unittest涓涓皬bughttp://m.shnenglu.com/cpunion/archive/2006/09/16/12536.htmlqieziqieziSat, 16 Sep 2006 01:32:00 GMThttp://m.shnenglu.com/cpunion/archive/2006/09/16/12536.htmlhttp://m.shnenglu.com/cpunion/comments/12536.htmlhttp://m.shnenglu.com/cpunion/archive/2006/09/16/12536.html#Feedback0http://m.shnenglu.com/cpunion/comments/commentRss/12536.htmlhttp://m.shnenglu.com/cpunion/services/trackbacks/12536.html
development_pgsql:
聽(tīng)聽(tīng)adapter
:聽(tīng)postgresql
聽(tīng)聽(tīng)database
:聽(tīng)myproject_development
聽(tīng)聽(tīng)username
:聽(tīng)postgres
聽(tīng)聽(tīng)password
:聽(tīng)

development_mysql
:
聽(tīng)聽(tīng)adapter
:聽(tīng)mysql
聽(tīng)聽(tīng)database
:聽(tīng)myproject_development
聽(tīng)聽(tīng)username
:聽(tīng)root
聽(tīng)聽(tīng)password
:聽(tīng)

development
:
聽(tīng)聽(tīng)development_mysql

test
:
聽(tīng)聽(tīng)adapter
:聽(tīng)postgresql
聽(tīng)聽(tīng)database
:聽(tīng)myproject_test
聽(tīng)聽(tīng)username
:聽(tīng)postgres
聽(tīng)聽(tīng)password
:聽(tīng)

production
:
聽(tīng)聽(tīng)development

姝e父榪愯娌′粈涔堥棶棰樸傚悗鏉ュ彂鐜板湪榪愯rake test浣滃崟鍏冩祴璇曟椂浼?xì)鎶ラ敊锛屾妸鎷疯礉杩囨潵灏辨病鏈夐棶棰樸備笉榪噐ubyonrails.com涓婁笉鍏佽鍖垮悕鎻愪氦bug錛岃繕鐪熼夯鐑?chǔ)銆?br />
鍙﹀鍙戠幇config.active_record.schema_format = :ruby閰嶇疆涓嬶紝postgresql鐨則imestamp瀛楁榛樿鍊糲urrent_timestamp涓嶈兘姝g‘澶嶅埗鍒版暟鎹簱銆傜粡媯(gè)鏌ュ畠鏄嬌鐢╠b:schema:dump澶嶅埗涓嬫暟鎹簱妯″紡錛屽啀浣跨敤db:schema:load鐢熸垚嫻嬭瘯鏁版嵁搴撴ā寮忕殑錛岃繖涓ā鍧椾負(fù)浜?jiǎn)鍚勬暟鎹簱缁熶竴錛屼細(xì)鍘繪帀閭d簺涓嶄竴鑷寸殑榛樿鍊箋傝В鍐沖姙娉曟槸璁劇疆config.active_record.schema_format = :sql銆?img src ="http://m.shnenglu.com/cpunion/aggbug/12536.html" width = "1" height = "1" />

qiezi 2006-09-16 09:32 鍙戣〃璇勮
]]>
[RoR] 淇update_attribute(s)鏇存柊鍏ㄩ儴瀛楁鐨勯棶棰?/title><link>http://m.shnenglu.com/cpunion/archive/2006/08/26/11712.html</link><dc:creator>qiezi</dc:creator><author>qiezi</author><pubDate>Fri, 25 Aug 2006 18:10:00 GMT</pubDate><guid>http://m.shnenglu.com/cpunion/archive/2006/08/26/11712.html</guid><wfw:comment>http://m.shnenglu.com/cpunion/comments/11712.html</wfw:comment><comments>http://m.shnenglu.com/cpunion/archive/2006/08/26/11712.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/cpunion/comments/commentRss/11712.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/cpunion/services/trackbacks/11712.html</trackback:ping><description><![CDATA[<span id="xbpx39z" class="postbody">榪欐槸鍓嶆鏃墮棿鏈変漢璁ㄨ榪囩殑闂錛?<br /></span> <table cellspacing="1" cellpadding="3" width="90%" align="center" border="0"> <tbody> <tr> <td> <span id="vjddrlx" class="genmed"> <b>浠g爜:</b> </span> </td> </tr> <tr> <td class="code"> <br />order = Order.find(1) <br />order.update_attribute(:status, 'finished') <br /></td> </tr> </tbody> </table> <span id="93vdjrd" class="postbody"> <br />鍋囧畾orders琛ㄦ湁10涓瓧孌碉紝浣犲彧鎯蟲(chóng)洿鏂板叾涓竴涓紝浣哸ctive record浼?xì)鐢熸垚涓涓洿鏂板叏閮ㄥ瓧孌電殑SQL璇彞錛屽亣瀹氬叾涓竴涓瓧孌靛奸暱搴︽槸20K錛岃繖涓礋鎷呭彲鑳戒細(xì)鏈変簺閲嶃?<br /><br />鎴戝皾璇曡В鍐寵繖涓棶棰橈紝鍐欎簡(jiǎn)涓畝鍗曠殑鎻掍歡錛?<br /></span> <table cellspacing="1" cellpadding="3" width="90%" align="center" border="0"> <tbody> <tr> <td> <span id="fjdz1r3" class="genmed"> <b>浠g爜:</b> </span> </td> </tr> <tr> <td class="code"> <br />module ActiveRecord <br />聽(tīng) class Base <br />聽(tīng) 聽(tīng) def update_attribute(name, value) <br />聽(tīng) 聽(tīng) 聽(tīng) update_attributes(name => value) <br />聽(tīng) 聽(tīng) end <br /><br />聽(tīng) 聽(tīng) def update_attributes(new_attributes) <br />聽(tīng) 聽(tīng) 聽(tīng) return if new_attributes.nil? <br />聽(tīng) 聽(tīng) 聽(tīng) attributes = new_attributes.dup <br />聽(tīng) 聽(tīng) 聽(tīng) attributes.stringify_keys! <br />聽(tīng) 聽(tīng) 聽(tīng) self.attributes = attributes <br />聽(tīng) 聽(tīng) 聽(tīng) update(attributes) <br />聽(tīng) 聽(tīng) end <br /><br />聽(tīng) 聽(tīng) private <br />聽(tīng) 聽(tīng) 聽(tīng) def update(attrs = nil) <br />聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) connection.update( <br />聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) "UPDATE #{self.class.table_name} " + <br />聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) "SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false, attrs))} " + <br />聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) "WHERE #{self.class.primary_key} = #{quote(id)}", <br />聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) "#{self.class.name} Update" <br />聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) ) <br />聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) <br />聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) return true <br />聽(tīng) 聽(tīng) 聽(tīng) end <br /><br />聽(tīng) 聽(tīng) 聽(tīng) def attributes_with_quotes(include_primary_key = true, attrs = nil) <br />聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) (attrs || attributes).inject({}) do |quoted, (name, value)| <br />聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) if column = column_for_attribute(name) <br />聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) quoted[name] = quote(value, column) unless !include_primary_key && column.primary <br />聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) end <br />聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) quoted <br />聽(tīng) 聽(tīng) 聽(tīng) 聽(tīng) end <br />聽(tīng) 聽(tīng) 聽(tīng) end <br />聽(tīng) end <br />end <br /></td> </tr> </tbody> </table> <span id="n33d9t3" class="postbody"> <p> <br />attributes_with_quotes鍑芥暟鐨勫弬鏁版悶榪欎箞澶嶆潅錛屽師鍥犳槸鎴戞兂鍗充究鏄敤榪欐浠g爜鏇挎崲搴撻噷闈㈢殑閮ㄥ垎錛屼篃涓嶅獎(jiǎng)鍝嶅師鏈変唬鐮佺殑姝e父鍔熻兘銆?<br /><br />鍙互綆鍗曟祴璇曚竴涓嬩笂闈㈢殑渚嬪瓙錛屽畠鐢熸垚鐨凷QL璇彞浼?xì)绠媧佸緢澶氾紝澶ф鏄繖鏍峰瓙錛?<br />UPDATE orders SET "status" = 'finished' WHERE id = 1<br /><br /><strong>宸插彂鐜扮殑BUG鍜屼慨澶嶏細(xì)<br /></strong><br /><strong>1銆佹病鏈夎皟鐢╲alidation (by cookoo)銆?/strong>鐢變簬鍘熸湁浠g爜璋冪敤save錛岃宻ave琚鐩栨垚鏈夐獙璇佺殑浠g爜錛屾墍浠ュ叿鏈夐獙璇佸姛鑳姐傝В鍐沖姙娉曟槸澧炲姞涓孌典唬鐮侊細(xì)</p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <span style="COLOR: #000000">module聽(tīng)ActiveRecord<br />聽(tīng)聽(tīng)module聽(tīng)ValidationsFix<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)</span> <span style="COLOR: #0000ff">def</span> <span style="COLOR: #000000">聽(tīng)self.append_features(base)聽(tīng)</span> <span style="COLOR: #008000">#</span> <span style="COLOR: #008000">聽(tīng):nodoc:</span> <span style="COLOR: #008000"> <br /> </span> <span style="COLOR: #000000">聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)super<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)base.class_eval聽(tīng)do<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)alias_method聽(tīng):update_attributes_without_validation,聽(tīng):update_attributes<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)alias_method聽(tīng):update_attributes,聽(tīng):update_attributes_with_validation<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)end<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)end<br /><br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)</span> <span style="COLOR: #0000ff">def</span> <span style="COLOR: #000000">聽(tīng)update_attributes_with_validation(new_attributes)<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)</span> <span style="COLOR: #0000ff">return</span> <span style="COLOR: #000000">聽(tīng)</span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000">聽(tīng)new_attributes.nil?<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) attributes = new_attributes.dup<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) attributes.stringify_keys!<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)self.attributes聽(tīng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽(tīng)attributes<br /><br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)</span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000">聽(tīng)valid?<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)update_attributes_without_validation(attributes)<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)</span> <span style="COLOR: #0000ff">else</span> <span style="COLOR: #000000"> <br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)</span> <span style="COLOR: #0000ff">return</span> <span style="COLOR: #000000">聽(tīng)false<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)end<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)end<br />聽(tīng)聽(tīng)end<br />end<br /><br />ActiveRecord::Base.class_eval聽(tīng)do<br />聽(tīng)聽(tīng)include聽(tīng)ActiveRecord::ValidationsFix<br />end</span> </div> <p>綆鍗曟祴璇曢氳繃銆?/p> </span><img src ="http://m.shnenglu.com/cpunion/aggbug/11712.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/cpunion/" target="_blank">qiezi</a> 2006-08-26 02:10 <a href="http://m.shnenglu.com/cpunion/archive/2006/08/26/11712.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>[ROR] &:id榪欑鐢ㄦ硶http://m.shnenglu.com/cpunion/archive/2006/07/11/9688.htmlqieziqieziTue, 11 Jul 2006 07:40:00 GMThttp://m.shnenglu.com/cpunion/archive/2006/07/11/9688.htmlhttp://m.shnenglu.com/cpunion/comments/9688.htmlhttp://m.shnenglu.com/cpunion/archive/2006/07/11/9688.html#Feedback0http://m.shnenglu.com/cpunion/comments/commentRss/9688.htmlhttp://m.shnenglu.com/cpunion/services/trackbacks/9688.html
class Symbol
聽(tīng) def to_proc
聽(tīng)聽(tīng)聽(tīng) Proc.new { |*args| args.shift.__send__(self, *args) }
聽(tīng) end
end

瀹冩墿灞曞嚭榪欑鐢ㄦ硶錛?br />
(1..5).map(&:to_s)

map鍘熸湰鏄鎺ュ彈涓涓猙lock鍙傛暟錛屾櫘閫氱殑鐢ㄦ硶鏄細(xì)

(1..5).map{|e| e.to_s}

鎴栬咃細(xì)

proc = Proc.new{|e| e.to_s}
(1..5).map(&proc)

涓婇潰榪欎釜(1..5).map(&:to_s)鐢ㄦ硶鍙互鎷嗘垚3姝ユ潵瑙i噴錛?br />sym = :to_s
proc = Proc.new{|*args| args.shift.send(sym, *args)}
(1..5).map(&proc)

鏈変釜鐤戦棶錛岀粡榪噛anping.jia瑙i噴錛宮ap(&:to_s)鍥犱負(fù)鍑虹幇浜?amp;絎﹀彿錛屾墍浠?to_s浼?xì)鎵цto_proc鏂規(guī)硶錛岀劧鍚庝笌&涓璧峰悎鎴?amp;proc浜ょ粰map澶勭悊銆傝櫧鐒惰寰楅氾紝涓嶈繃鎴戞昏寰楄繖涓В閲婁腑錛?amp;榪欎釜絎﹀彿鍋氫簡(jiǎn)2嬈″伐浣滐紝鏄惁鍚堢悊錛?br />
榪欑鐢ㄦ硶鍘熸湰鏄疪uby Extensions Project鍙戞槑鐨勶紝鍦≧oR涓綔浜?jiǎn)鐐逛慨鏀广傚師鏉ョ殑鐗堟湰鏄細(xì)

class Symbol
聽(tīng)聽(tīng)聽(tīng) def to_proc
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) proc { |obj, *args| obj.send(self, *args) }
聽(tīng)聽(tīng)聽(tīng) end
end

瀹冧嬌鐢?涓弬鏁版潵鍒嗗嚭涓涓弬鏁幫紝鑰孯oR鐗堟湰鍒欎嬌鐢╯hift鍒嗗嚭鏉ャ?br />

鍒氭墠鍙堟兂浜?jiǎn)涓涓嬶紝yanping.jia鐨勮В閲婂簲璇ユ槸鍚堢悊鐨勶紝瑙i噴鍣ㄧ湅鍒?amp;:id鏃訛紝鍏堜細(xì)鍒ゆ柇鏄惁鏄竴涓柟娉曡皟鐢紝濡傛灉鏄垯闇瑕佹妸:id杞垚涓涓猵roc銆傚惁鍒欏氨鏄娉曢敊璇簡(jiǎn)銆?img src ="http://m.shnenglu.com/cpunion/aggbug/9688.html" width = "1" height = "1" />

qiezi 2006-07-11 15:40 鍙戣〃璇勮
]]>
[ROR] 淇鈥滀嬌鐢≒OST鏂規(guī)硶鏃?閫氳繃URL鍙傛暟鏀瑰啓_session_id鏃犳晥鈥濈殑闂http://m.shnenglu.com/cpunion/archive/2006/07/03/9346.htmlqieziqieziMon, 03 Jul 2006 15:58:00 GMThttp://m.shnenglu.com/cpunion/archive/2006/07/03/9346.htmlhttp://m.shnenglu.com/cpunion/comments/9346.htmlhttp://m.shnenglu.com/cpunion/archive/2006/07/03/9346.html#Feedback1http://m.shnenglu.com/cpunion/comments/commentRss/9346.htmlhttp://m.shnenglu.com/cpunion/services/trackbacks/9346.html
浣跨敤Flash 8鎻愪緵鐨凢ileReference鍙互鏂逛究鍦頒竴嬈¢夋嫨澶氫釜鏂囦歡涓婁紶錛屼笉榪囬櫎浜?jiǎn)鍦↖E涓婁互澶栵紝鍏跺畠嫻忚鍣ㄤ笂鐨勯兘浼?xì)鍑虹幇Cookie涓庢祻瑙堝櫒涓嶄竴鑷寸殑闂銆?br />
瑙e喅鍔炴硶錛? 鐩存帴鐨勫仛娉曞氨鏄湪涓婁紶鏃訛紝闄勫姞涓涓猻ession_id鍦║RL涓婏紝鍦ㄦ湇鍔$澶勭悊鏃朵嬌鐢ㄨ繖涓猄ession銆?br />
鍦≧ails涓紝鍙互鎶奯session_id=xxxx闄勫姞鍦║RL涓娿備笉榪囨祴璇曠殑緇撴灉鏄紝闄勫姞鐨剆ession_id鍙湁鍦℅ET璇鋒眰鏃舵墠姝e父錛孭OST璇風(fēng)ず鏃朵細(xì)琚拷鐣ャ?br />
鐭ラ亾浜?jiǎn)杩欎竴鐐癸紝鍙渶瑕佸鎵綠ET鍜孭OST璇鋒眰澶勭悊鐨勫樊鍒備篃璐逛簡(jiǎn)涓鐣懆鎶橈紝鎵嶅彂鐜伴棶棰樺嚭鍦╝ctionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb閲屻?br />
鍙渶瑕佸湪POST鏃朵篃澶勭悊涓涓婾RL鍙傛暟鍗沖彲銆傜敱浜庡畠鏄氳繃read_query_params鏂規(guī)硶鏉ュ垎寮澶勭悊鐨勶紝鎵浠ヨ鍦≒OST璇鋒眰鏃訛紝璋冪敤涓涓媟ead_query_params(:get)錛屽茍鎶婄粨鏋滃悎騫躲備唬鐮佸涓嬶細(xì)

@params.merge!(CGI.parse(read_query_params(:get))) if method == :post || method == :put

榪欒鍔犲埌initialize_query鏂規(guī)硶灝鵑儴鍗沖彲銆傜敱浜庡師鏉ョ殑鏂規(guī)硶鍙兘榪斿洖浜?jiǎn)@params錛屾墍浠ヤ篃鍔犱竴琛孈params鍦ㄧ粨灝撅紝浠ュ厤閫犳垚涓嶅繀瑕佺殑楹葷儲(chǔ)銆?img src ="http://m.shnenglu.com/cpunion/aggbug/9346.html" width = "1" height = "1" />

qiezi 2006-07-03 23:58 鍙戣〃璇勮
]]>
[RoR] 瀹炵幇涓涓猘uto_redirect_tohttp://m.shnenglu.com/cpunion/archive/2006/05/20/7434.htmlqieziqieziFri, 19 May 2006 18:33:00 GMThttp://m.shnenglu.com/cpunion/archive/2006/05/20/7434.htmlhttp://m.shnenglu.com/cpunion/comments/7434.htmlhttp://m.shnenglu.com/cpunion/archive/2006/05/20/7434.html#Feedback0http://m.shnenglu.com/cpunion/comments/commentRss/7434.htmlhttp://m.shnenglu.com/cpunion/services/trackbacks/7434.html
鎴戦亣鍒扮殑涓涓棶棰樻槸錛屽綋浣跨敤Ajax鏇存柊欏甸潰灞閮ㄥ唴瀹規(guī)椂錛宻ession鍐呭宸茬粡榪囨湡錛岃繖鏃墮渶瑕佹暣涓〉闈㈣煩杞埌鐧誨綍欏甸潰銆?br />
鐩存帴璋冪敤redirect_to浼?xì)鋴慑眬閮ㄥ唴瀹規(guī)樉紺烘垚鐧誨綍欏甸潰錛屽畠鏄湪HTTP澶撮噷鍐欏叆閲嶅畾鍚戝弬鏁版潵瀹炵幇鐨勩傚湪鎴戣繖閲岀殑鐗規(guī)畩鎯呭喌涓嬶紝姝g‘鐨勫仛娉曟槸璁╁畠鎵ц涓涓寘鍚湪<script>鏍囪涓殑鑴氭湰錛屽湪鑴氭湰涓洿鏀圭獥鍙ocation鍊兼潵璺寵漿銆?br />
涓嶈繃RoR涓嬌鐢ˋjax鏃訛紝浼?xì)鏍规?update鍙傛暟鏉ュ喅瀹氭槸浣跨敤Updater榪樻槸Request銆傚鏋滀嬌鐢║pdater鏂瑰紡錛屽垯搴旇繑鍥炰竴孌電函鑴氭湰錛涘鏋滄槸Request鏂瑰紡錛屽簲榪斿洖涓孌靛寘鎷湪<script>鏍囪涓殑鑴氭湰錛涘鏋滄槸鏅氭柟寮忥紝灝卞簲璇ヤ嬌鐢ㄥ師鏈夌殑redirect_to鍑芥暟浜?jiǎn)銆傚洜涓烘湇鍔$鏃犳硶鍖哄垎浣跨敤鐨勬槸鍝鏂瑰紡鏉ヨ姹傦紝鎵浠ョ畝鍗曠殑鍋氭硶鏄瘡涓姹傞兘闄勫姞涓涓弬鏁扮敤鏉ュ尯鍒嗭紝涓嶅姞鍙傛暟鍒欐槸鏅氳姹傛柟寮忋?br />
涓轟簡(jiǎn)杈懼埌榪欎釜鐩殑錛屾垜淇敼浜?jiǎn)prototype_helper涓殑remote_function鍑芥暟銆傝繖涓嚱鏁版牴鎹紶閫掕繘鏉ョ殑鍙傛暟鏉ュ喅瀹氫嬌鐢≧equest鎴栨槸Updater錛屾垜灝卞湪榪欓噷涓嬫墜錛?br />
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)remote_function(options)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)javascript_options聽(tīng)
=聽(tīng)options_for_ajax(options)

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)update聽(tīng)
=聽(tīng)''
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
if聽(tīng)options[:update]聽(tīng)and聽(tīng)options[:update].is_a?Hash
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)update聽(tīng)聽(tīng)
=聽(tīng)[]
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)update聽(tīng)
<<聽(tīng)"success:'#{options[:update][:success]}'"聽(tīng)if聽(tīng)options[:update][:success]
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)update聽(tīng)
<<聽(tīng)"failure:'#{options[:update][:failure]}'"聽(tīng)if聽(tīng)options[:update][:failure]
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)update聽(tīng)聽(tīng)
=聽(tīng)'{'聽(tīng)+聽(tīng)update.join(',')聽(tīng)+聽(tīng)'}'
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)elsif聽(tīng)options[:update]
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)update聽(tīng)
<<聽(tīng)"'#{options[:update]}'"
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)function聽(tīng)
=聽(tīng)update.empty?聽(tīng)?聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
"new聽(tīng)Ajax.Request("聽(tīng):
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
"new聽(tīng)Ajax.Updater(#{update},聽(tīng)"
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)url_options聽(tīng)
=聽(tīng)options[:url]
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)ajax_options聽(tīng)
=聽(tīng)options[:update]聽(tīng)?聽(tīng){:ajax聽(tīng)=>聽(tīng)'update'}聽(tīng):聽(tīng){:ajax聽(tīng)=>聽(tīng)'request'}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)url_options聽(tīng)
=
聽(tīng)url_options.merge(ajax_options)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)url_options聽(tīng)
=聽(tīng)url_options.merge(:escape聽(tīng)=>聽(tīng)false)聽(tīng)if聽(tīng)url_options.is_a?聽(tīng)Hash
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)function聽(tīng)
<<聽(tīng)"'#{url_for(url_options)}'"
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)function聽(tīng)
<<聽(tīng)",聽(tīng)#{javascript_options})"

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)function聽(tīng)
=聽(tīng)"#{options[:before]};聽(tīng)#{function}"聽(tīng)if聽(tīng)options[:before]
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)function聽(tīng)
=聽(tīng)"#{function};聽(tīng)#{options[:after]}"聽(tīng)聽(tīng)if聽(tīng)options[:after]
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)function聽(tīng)
=聽(tīng)"if聽(tīng)(#{options[:condition]})聽(tīng){聽(tīng)#{function};聽(tīng)}"聽(tīng)if聽(tīng)options[:condition]
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)function聽(tīng)
=聽(tīng)"if聽(tīng)(confirm('#{escape_javascript(options[:confirm])}'))聽(tīng){聽(tīng)#{function};聽(tīng)}"聽(tīng)if聽(tīng)options[:confirm]

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
return聽(tīng)function
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)end

鏈夌孩鑹茬殑2琛屾槸鎴戞坊鍔犵殑錛岀敱浜庤繖涓紪杈戝櫒鐨勫師鍥狅紝娌℃湁鏄劇ず鎴愭暣琛岀孩鑹層傝繖2琛岀殑浣滅敤鏄垽鏂槸鍚︽湁:update鍙傛暟錛岀敤瀹冩潵鍐沖畾鏄坊鍔燼jax=update榪樻槸ajax=request銆?br />
鐜板湪鍙互瀹炵幇涓涓畝鍗曠殑auto_redirect_to浜?jiǎn)锛?xì)

聽(tīng)聽(tīng)def聽(tīng)auto_redirect_to(method,聽(tīng)url)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
case聽(tīng)method
聽(tīng)聽(tīng)聽(tīng)聽(tīng)when聽(tīng)
'request'
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)request_redirect_to(url)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)when聽(tīng)
'update'
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)update_redirect_to(url)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
else
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)redirect_to(url)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)
聽(tīng)聽(tīng)def聽(tīng)request_redirect_to(url)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)render聽(tīng):update聽(tīng)
do聽(tīng)|page|
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)page.redirect_to(url)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)
聽(tīng)聽(tīng)def聽(tīng)update_redirect_to(url)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)render聽(tīng):inline聽(tīng)
=>聽(tīng)<<-EOS
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
<script聽(tīng)language="javascript">
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
<%=
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)render聽(tīng):update聽(tīng)
do聽(tīng)|page|
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)page.redirect_to(
"#{url_for(url)}")
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
%>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
</script>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)EOS
聽(tīng)聽(tīng)end

浣跨敤helper鏂瑰紡浣垮畠鑳藉琚玦nclude鍒癆pplicationController涓氨琛屼簡(jiǎn)銆?br />
涓轟簡(jiǎn)涓嶅拰鍙傛暟緇戝緱澶錛岃繖閲屾妸method浣滀負(fù)鍙傛暟鐢辮皟鐢ㄨ呬紶鍏ャ?br />
浣跨敤鏂規(guī)硶錛屼互Login Engine涓轟緥錛屽畠鍦╝ccess_denied涓鐞嗚煩杞傚湪ApplicationController涓噸鍐欒繖涓嚱鏁幫細(xì)

聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)access_denied
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)auto_redirect_to(
params[:ajax],聽(tīng):controller聽(tīng)=>聽(tīng)"/user",聽(tīng):action聽(tīng)=>聽(tīng)"login")
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
false
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end聽(tīng)聽(tīng)

鐜板湪鍙互嫻嬭瘯浜?jiǎn)銆傝姹傚彲浠ユ槸鏅氱殑錛堣秴閾炬帴錛夛紝Updater鏂瑰紡錛堣姹傚埌涓涓狣IV閲岋級(jí)錛孯equest鏂瑰紡錛岀幇鍦ㄩ兘鑳藉璺寵漿鍒版紜〉闈€?br />
ajax鍙傛暟閫氳繃hack搴撲唬鐮佹潵瀹炵幇錛屽浜庝嬌鐢ㄨ呮潵璇村熀鏈笂鏄忔槑鐨勩?br />

qiezi 2006-05-20 02:33 鍙戣〃璇勮
]]>
[RoR] 鍦≧oR涓皟鐢?Net webservicehttp://m.shnenglu.com/cpunion/archive/2006/05/14/7138.htmlqieziqieziSun, 14 May 2006 12:08:00 GMThttp://m.shnenglu.com/cpunion/archive/2006/05/14/7138.htmlhttp://m.shnenglu.com/cpunion/comments/7138.htmlhttp://m.shnenglu.com/cpunion/archive/2006/05/14/7138.html#Feedback0http://m.shnenglu.com/cpunion/comments/commentRss/7138.htmlhttp://m.shnenglu.com/cpunion/services/trackbacks/7138.html
using聽(tīng)System;
using聽(tīng)System.Web;
using聽(tīng)System.Web.Services;
using聽(tīng)System.Web.Services.Protocols;

[WebService(Namespace聽(tīng)
=聽(tīng)"http://tempuri.org/")]
[WebServiceBinding(ConformsTo聽(tīng)
=聽(tīng)WsiProfiles.BasicProfile1_1)]
public聽(tīng)class聽(tīng)Service聽(tīng):聽(tīng)System.Web.Services.WebService
{
聽(tīng)聽(tīng)聽(tīng)聽(tīng)[WebMethod]
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
public聽(tīng)string聽(tīng)HelloWorld(string聽(tīng)name)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
return聽(tīng)"Hello,聽(tīng)"聽(tīng)+聽(tīng)name;
聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
}

鍦≧oR欏圭洰閲岋紝娣誨姞app/apis/test_api.rb錛?br />
class聽(tīng)TestApi聽(tīng)<聽(tīng)ActionWebService::API::Base
聽(tīng)聽(tīng)api_method聽(tīng):HelloWorld,聽(tīng):expects聽(tīng)
=>聽(tīng)[{:name聽(tīng)=>聽(tīng):string}],聽(tīng):returns聽(tīng)=>聽(tīng)[:string]
end

榪欐槸RoR閲岄潰閫氱敤鐨剋ebservice鍏冧俊鎭弿榪般?br />
娣誨姞app/controllers/test_controller.rb:

class聽(tīng)TestController聽(tīng)<聽(tīng)ApplicationController
聽(tīng)聽(tīng)web_client_api聽(tīng):test,聽(tīng):soap,聽(tīng)
"http://localhost/test/Service.asmx",聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng):namespace聽(tīng)
=>聽(tīng)"http://tempuri.org/",
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng):soap_action_base聽(tīng)
=>聽(tīng)"http://tempuri.org",
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng):driver_options
=>{:default_encodingstyle聽(tīng)=>聽(tīng)SOAP::EncodingStyle::ASPDotNetHandler::Namespace聽(tīng)}

聽(tīng)聽(tīng)
def聽(tīng)hello
聽(tīng)聽(tīng)聽(tīng)聽(tīng)render_text聽(tīng)test.HelloWorld(
"Li聽(tīng)Jie")
聽(tīng)聽(tīng)end
end

:soap_action_base閫夐」鏄竴涓慨琛ワ紝涓嶅姞榪欎釜閫夐」浼?xì)漶旂敓SOAPAction澶撮敊璇?br />
榪愯鏈嶅姟鍣紝鍦ㄦ祻瑙堝櫒涓闂?test/hello錛屽彂鐜板悕瀛椾負(fù)絀恒傜粡榪囬暱鏃墮棿璋冭瘯錛屽彂鐜?Net鍦ㄨВ鏋怱OAP娑堟伅浣撴椂錛屼笉鑳藉鐞嗚繖縐嶅懡鍚嶇┖闂達(dá)細(xì)

聽(tīng)聽(tīng)聽(tīng)聽(tīng)<n1:HelloWorld聽(tīng)xmlns:n1="http://tempuri.org/"
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)soap:encodingStyle
="http://schemas.xmlsoap.org/soap/encoding/">
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
<name聽(tīng)xsi:type="xsd:string">Li Jie</name>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
</n1:HelloWorld>

鎶妌1鍘繪帀灝辮浜?jiǎn)銆備笉榪囪繖閮ㄥ垎瀹炵幇鍦╮ubylib/soap/rpc/proxy.rb閲岄潰錛屽疄鍦ㄤ笉鏂逛究淇敼銆備負(fù)浜?jiǎn)璁q欎釜嫻嬭瘯閫氳繃錛屾殏鏃跺仛浜?jiǎn)鐐篂畯淇敼锛?xì)

聽(tīng)聽(tīng)def聽(tīng)route(req_header,聽(tīng)req_body,聽(tīng)reqopt,聽(tīng)resopt)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)req_env聽(tīng)
=聽(tīng)::SOAP::SOAPEnvelope.new(req_header,聽(tīng)req_body)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)unless聽(tīng)reqopt[:envelopenamespace].nil?
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)set_envelopenamespace(req_env,聽(tīng)reqopt[:envelopenamespace])
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)聽(tīng)聽(tīng)reqopt[:external_content]聽(tīng)
=聽(tīng)nil
聽(tīng)聽(tīng)聽(tīng)聽(tīng)conn_data聽(tīng)
=聽(tīng)marshal(req_env,聽(tīng)reqopt)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
if聽(tīng)ext聽(tīng)=聽(tīng)reqopt[:external_content]
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)mime聽(tīng)
=聽(tīng)MIMEMessage.new
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)ext.each聽(tīng)do聽(tīng)
|k,聽(tīng)v|
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)mime.add_attachment(v.data)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)mime.add_part(conn_data.send_string聽(tīng)
+聽(tīng)"\r\n")
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)mime.close
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)conn_data.send_string聽(tīng)
=聽(tīng)mime.content_str
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)conn_data.send_contenttype聽(tīng)
=聽(tīng)mime.headers['content-type'].str
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)聽(tīng)聽(tīng)conn_data.send_string.gsub!(
/:n1/,聽(tīng)'')
聽(tīng)聽(tīng)聽(tīng)聽(tīng)conn_data.send_string.gsub!(
/n1:/,聽(tīng)''
)

聽(tīng)聽(tīng)聽(tīng)聽(tīng)conn_data聽(tīng)
=聽(tīng)@streamhandler.send(@endpoint_url,聽(tīng)conn_data,
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)reqopt[:soapaction])
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
if聽(tīng)conn_data.receive_string.empty?
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
return聽(tīng)nil
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)聽(tīng)聽(tīng)unmarshal(conn_data,聽(tīng)resopt)
聽(tīng)聽(tīng)end

鍔犵矖鐨?琛屾槸鎴戞坊鍔犵殑浠g爜錛屽媺寮哄彲浠ヨ瀹冨伐浣滐紝涓嶈繃鏄劇劧涓嶆槸姝g‘鐨勬柟娉曘?br />
涓嶇煡閬撴槸涓嶆槸.Net搴撻噷闈㈢殑BUG銆?img src ="http://m.shnenglu.com/cpunion/aggbug/7138.html" width = "1" height = "1" />

qiezi 2006-05-14 20:08 鍙戣〃璇勮
]]>
[RoR] 鑴氭湰妯℃嫙RJS鍒鋒柊欏甸潰http://m.shnenglu.com/cpunion/archive/2006/05/13/7087.htmlqieziqieziSat, 13 May 2006 15:49:00 GMThttp://m.shnenglu.com/cpunion/archive/2006/05/13/7087.htmlhttp://m.shnenglu.com/cpunion/comments/7087.htmlhttp://m.shnenglu.com/cpunion/archive/2006/05/13/7087.html#Feedback0http://m.shnenglu.com/cpunion/comments/commentRss/7087.htmlhttp://m.shnenglu.com/cpunion/services/trackbacks/7087.html
婕旂ず欏甸潰鐩存帴鍦ㄦ祻瑙堝櫒涓鐪嬨?br />
婕旂ず涓嬭澆

qiezi 2006-05-13 23:49 鍙戣〃璇勮
]]>
[RoR] 鐢╦avascript鑴氭湰妯℃嫙涓涓猘ctionhttp://m.shnenglu.com/cpunion/archive/2006/05/12/7046.htmlqieziqieziFri, 12 May 2006 15:41:00 GMThttp://m.shnenglu.com/cpunion/archive/2006/05/12/7046.htmlhttp://m.shnenglu.com/cpunion/comments/7046.htmlhttp://m.shnenglu.com/cpunion/archive/2006/05/12/7046.html#Feedback0http://m.shnenglu.com/cpunion/comments/commentRss/7046.htmlhttp://m.shnenglu.com/cpunion/services/trackbacks/7046.html
鏈変簺鏃跺欐垜浠茍涓嶉渶瑕佽姹傛湇鍔″櫒錛屽彧鎯沖湪嫻忚鍣ㄤ笂鎵ц鏌愪簺鑴氭湰鏇存柊錛屼絾鍙堟兂浣跨敤RJS銆傛墍浠ヤ負(fù)RoR澧炲姞浜?jiǎn)杩櫃骞鍔熻兘銆?br />
浣跨敤鏂規(guī)硶錛?br />
<script聽(tīng)language="javascript">
<%=聽(tīng)
render聽(tīng):update聽(tīng)do聽(tīng)
|page|
聽(tīng)聽(tīng)page.define_action聽(tīng)
'test_action'聽(tīng)do
聽(tīng)聽(tīng)聽(tīng)聽(tīng)page.call_script聽(tīng)
<<-EOS
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)alert(params.comment.title);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)alert(params.comment.body);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)EOS
聽(tīng)聽(tīng)聽(tīng)聽(tīng)page.replace_html聽(tīng)
'errors',聽(tīng)'ERROR'
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)page.define_action聽(tīng)
'link_action'聽(tīng)do
聽(tīng)聽(tīng)聽(tīng)聽(tīng)page.replace_html聽(tīng)
'errors',聽(tīng)'ERROR'
聽(tīng)聽(tīng)end
end
%>
</script>

<div聽(tīng)id="errors"></div>

<%=聽(tīng)form_local_tag聽(tīng):html聽(tīng)=>聽(tīng){:action聽(tīng)=>聽(tīng)'test_action'}聽(tīng)%>
聽(tīng)聽(tīng)
<input聽(tīng)name="comment[title]"聽(tīng)/><br聽(tīng)/>
聽(tīng)聽(tīng)
<input聽(tīng)name="comment[body]"聽(tīng)/><br聽(tīng)/>
聽(tīng)聽(tīng)
<%=聽(tīng)submit_tag聽(tīng)'Create'聽(tīng)%>
<%=聽(tīng)end_form_tag聽(tīng)%>

<%=聽(tīng)link_to_local聽(tīng)'Test',聽(tīng):action聽(tīng)=>聽(tīng)'link_action()'聽(tīng)%>

涓婇潰婕旂ず浜?jiǎn)form_local_tag鍜宭ink_to_local鐨勪嬌鐢紝鎵撳紑榪欎釜欏甸潰浠ュ悗錛屽彲浠ュ叧鎺夋湇鍔″櫒嫻嬭瘯錛屼細(xì)鍙戠幇瀹冧笉璇鋒眰鏈嶅姟鍣ㄤ篃鑳芥墽琛岀浉搴旇剼鏈?br />
define_action瀹氫箟涓涓剼鏈嚱鏁幫紝call_script鐢ㄦ潵瀹炵幇javascript鍜孯JS浠g爜鐨勬販鍚堛傚綋浣跨敤form_local_tag鏃訛紝action鏂規(guī)硶鐨勫弬鏁板凡緇忚澶勭悊榪囷紝鎵浠ュ彲浠ョ洿鎺ュ湪action涓嬌鐢╬arams.comment.title銆?br />
褰撶劧鐜板湪榪樹(shù)笉瀹屽杽錛屾瘮濡傝繕鍙兘浣跨敤杞崲瀹岀殑欏甸潰妯℃澘錛屼竴浜涘姩鎬侀〉闈㈠皢鐪嬩笉鍑烘晥鏋溿傝鍋氬埌榪欑偣錛岄渶瑕佺敤javascript瀹炵幇涓鏁村鐨凙ctionView杈呭姪鏂規(guī)硶銆?br />
涓嬮潰鎻愪緵涓涓拡瀵箁ails 1.1.2鐨勪竴涓ˉ涓佹枃浠訛細(xì)

琛ヤ竵鏂囦歡涓嬭澆

qiezi 2006-05-12 23:41 鍙戣〃璇勮
]]>
[RoR] ActionController::Caching妯″潡緙撳瓨?shù)綅缃瓸UGhttp://m.shnenglu.com/cpunion/archive/2006/05/09/6814.htmlqieziqieziTue, 09 May 2006 03:35:00 GMThttp://m.shnenglu.com/cpunion/archive/2006/05/09/6814.htmlhttp://m.shnenglu.com/cpunion/comments/6814.htmlhttp://m.shnenglu.com/cpunion/archive/2006/05/09/6814.html#Feedback2http://m.shnenglu.com/cpunion/comments/commentRss/6814.htmlhttp://m.shnenglu.com/cpunion/services/trackbacks/6814.html
class聽(tīng)CacheController聽(tīng)<聽(tīng)ApplicationController
聽(tīng)聽(tīng)caches_action聽(tīng)
:cache_one
聽(tīng)聽(tīng)caches_page聽(tīng)聽(tīng)聽(tīng)
:cache_two
聽(tīng)聽(tīng)
#
end

class聽(tīng)TestController聽(tīng)<聽(tīng)ApplicationController
聽(tīng)聽(tīng)def聽(tīng)one
聽(tīng)聽(tīng)聽(tīng)聽(tīng)render聽(tīng)
:inline聽(tīng)=>聽(tīng)<<-EOS
Test
::one<br聽(tīng)/>
<%=聽(tīng)render_component聽(tīng):controller聽(tīng)=>聽(tīng)'cache',聽(tīng):action聽(tīng)=>聽(tīng)'cache_one'聽(tīng)%>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)EOS
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)two
聽(tīng)聽(tīng)聽(tīng)聽(tīng)render聽(tīng)
:inline聽(tīng)=>聽(tīng)<<-EOS
Test
::two<br聽(tīng)/>
<%=聽(tīng)render_component聽(tīng):controller聽(tīng)=>聽(tīng)'cache',聽(tīng):action聽(tīng)=>聽(tīng)'cache_two'聽(tīng)%>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)EOS
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)
#
end

cache_one鍜宑ache_two鐨勫疄鐜板氨鐪佺暐浜?jiǎn)銆?br />
璁塊棶鐩存帴璁塊棶榪?涓猘ction錛岃兘澶熷湪姝g‘鐨勭洰褰曚笅鐢熸垚緙撳瓨鏂囦歡銆備笉榪囪闂畉est/one鍜宼est/two灝變細(xì)鍑虹幇緙撳瓨閿欒錛?涓紦瀛樻枃浠惰鐢熸垚鍒癈ACHE_ROOT/test涓嬶紝璇曟兂濡傛灉鍦ㄥ涓湴鏂逛嬌鐢╮ender_component錛屽氨浼?xì)漶旂敓寰堝鋯句竴鏍峰唴瀹圭殑緙撳瓨銆?br />
request浼?xì)琚紶閫掔粰controller錛屽綋璁塊棶/test/one鏃訛紝榪欎釜request淇濈暀鏈夎繖涓猽rl銆傝皟鐢╮ender_component鏃訛紝浼?xì)鐢熸垚涓涓柊鐨刢ontroller錛岃繖涓猺equest涔熻浼犻掞紝涓嶈繃url鍗磋繕鏄?test/one錛屾墍浠ュ氨鏈夎繖涓棶棰樸?br />
淇錛?br />
module聽(tīng)ActionController聽(tīng)#:nodoc:
聽(tīng)聽(tīng)module聽(tīng)Caching
聽(tīng)聽(tīng)聽(tīng)聽(tīng)module聽(tīng)Actions
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)class聽(tīng)ActionCacheFilter聽(tīng)
#:nodoc:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)before(controller)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
return聽(tīng)unless聽(tīng)@actions.include?(controller.action_name.intern)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)url聽(tīng)
=聽(tīng)controller.url_for(:controller聽(tīng)=>聽(tīng)controller.controller_name,聽(tīng):action聽(tīng)=>聽(tīng)controller.action_name)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
if聽(tīng)cache聽(tīng)=聽(tīng)controller.read_fragment(url.split("://").last)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)controller
.rendered_action_cache聽(tīng)=聽(tīng)true
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)controller
.send(:render_text,聽(tīng)cache)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)false
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)after(controller)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
return聽(tīng)if聽(tīng)!@actions.include?(controller.action_name.intern)聽(tīng)||聽(tīng)controller.rendered_action_cache
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)url聽(tīng)
=聽(tīng)controller.url_for(:controller聽(tīng)=>聽(tīng)controller.controller_name,聽(tīng):action聽(tīng)=>聽(tīng)controller.action_name)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)controller
.write_fragment(url.split("://").last,聽(tīng)controller.response.body)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)end
end

閫氳繃鏇挎崲controller鍜宎ction鏉ヨВ鍐籌紝嫻嬭瘯緇撴灉姝g‘銆?br />
涓嶈繃榪樻湁鍏跺畠闂娌′慨澶嶏紝姣斿url涓弬鏁扮殑闂錛岃櫧鐒惰皟鐢╮ender_component鏃舵垜騫舵病鏈変紶閫掑弬鏁幫紝浣嗗畠榪樻槸鎶婂弬鏁扮粰浼犻掍簡(jiǎn)銆傚彟澶栨病鏈変慨澶峜aches_page鍜宖ragment銆?br />
鍏跺疄榪欎釜闂鏄敱render_component甯︽潵鐨勶紝鎵浠ユ渶濂界殑淇鍔炴硶褰撶劧鏄慨澶嶈繖涓柟娉曪紝璁╁畠澶勭悊姝g‘鐨刢ontroller/action/params錛屾殏鏃惰繕娌℃壘鍑轟慨澶嶆柟娉曘?br />


qiezi 2006-05-09 11:35 鍙戣〃璇勮
]]>
[RoR] 綆鍗曠殑瑙掕壊鏉冮檺媯(gè)鏌ユ彃浠?/title><link>http://m.shnenglu.com/cpunion/archive/2006/05/08/6790.html</link><dc:creator>qiezi</dc:creator><author>qiezi</author><pubDate>Mon, 08 May 2006 13:30:00 GMT</pubDate><guid>http://m.shnenglu.com/cpunion/archive/2006/05/08/6790.html</guid><wfw:comment>http://m.shnenglu.com/cpunion/comments/6790.html</wfw:comment><comments>http://m.shnenglu.com/cpunion/archive/2006/05/08/6790.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/cpunion/comments/commentRss/6790.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/cpunion/services/trackbacks/6790.html</trackback:ping><description><![CDATA[浠g爜姣旇緝綆鍗曪細(xì)<br /><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">module聽(tīng)ActionController聽(tīng)</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">:nodoc:</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000"><br />聽(tīng)聽(tīng)class聽(tīng)CheckGroupError聽(tīng)</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">聽(tīng)ActionControllerError聽(tīng)</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">:nodoc:</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">聽(tīng)聽(tīng)聽(tīng)聽(tīng)attr_reader聽(tīng)</span><span style="COLOR: #000000">:</span><span style="COLOR: #000000">group_name<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)initialize(group_name)<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)</span><span style="COLOR: #800080">@group_name</span><span style="COLOR: #000000">聽(tīng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(tīng)group_name<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)end<br />聽(tīng)聽(tīng)end<br />聽(tīng)聽(tīng)<br />聽(tīng)聽(tīng)class聽(tīng)CheckRoleError聽(tīng)</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">聽(tīng)ActionControllerError聽(tīng)</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">:nodoc:</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">聽(tīng)聽(tīng)聽(tīng)聽(tīng)attr_reader聽(tīng)</span><span style="COLOR: #000000">:</span><span style="COLOR: #000000">role_name<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)initialize(role_name)<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)</span><span style="COLOR: #800080">@role_name</span><span style="COLOR: #000000">聽(tīng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(tīng)role_name<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)end<br />聽(tīng)聽(tīng)end<br />聽(tīng)聽(tīng)<br />聽(tīng)聽(tīng)class聽(tīng)Base聽(tīng)</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">:nodoc:</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)roles<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)[]<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)end<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)groups<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)[]<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)end<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)check_roles(</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">role_args)<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)role_args</span><span style="COLOR: #000000">.</span><span style="COLOR: #0000ff">each</span><span style="COLOR: #000000">聽(tīng)</span><span style="COLOR: #0000ff">do</span><span style="COLOR: #000000">聽(tīng)</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000">role</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000"><br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)check_role(role)<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)end<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)end<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)check_groups(</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">group_args)<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)group_args</span><span style="COLOR: #000000">.</span><span style="COLOR: #0000ff">each</span><span style="COLOR: #000000">聽(tīng)</span><span style="COLOR: #0000ff">do</span><span style="COLOR: #000000">聽(tīng)</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000">group</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000"><br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)check_group(group)<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)end<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)end<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)check_group(group)<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)raise聽(tīng)CheckGroupError</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">new(group</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">to_s)聽(tīng)</span><span style="COLOR: #0000ff">unless</span><span style="COLOR: #000000">聽(tīng)groups()</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">include</span><span style="COLOR: #000000">?</span><span style="COLOR: #000000">(group</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">to_s)<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)end<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)check_role(role)<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)raise聽(tīng)CheckRoleError</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">new(role</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">to_s)聽(tīng)聽(tīng)聽(tīng)</span><span style="COLOR: #0000ff">unless</span><span style="COLOR: #000000">聽(tīng)roles()</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">include</span><span style="COLOR: #000000">?</span><span style="COLOR: #000000">(role</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">to_s)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)end<br />聽(tīng)聽(tīng)end<br />聽(tīng)聽(tīng)<br />end</span></div><br />鍙渶瑕佸湪ApplicationController涓疄鐜皉oles鍜実roups榪?涓柟娉曪紝瀵規(guī)暟鎹簱妯″紡娌℃湁浠諱綍闄愬埗錛屽彧瑕佽兘淇濊瘉榪?涓柟娉曡兘澶熷緱鍒板綋鍓嶇敤鎴風(fēng)殑瑙掕壊鍜岀粍鍗沖彲銆?br /><br />鏈?涓猚heck鏂規(guī)硶鍙敤錛屽彲浠繪剰浣跨敤涓涓垨澶氫釜銆?br /><br />綆鍗曟ā鎷熸祴璇曚竴涓嬶細(xì)<br /><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">class聽(tīng)ApplicationController聽(tīng)</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">聽(tīng)ActionController</span><span style="COLOR: #000000">::</span><span style="COLOR: #000000">Base<br />聽(tīng)聽(tīng)def聽(tīng)roles<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)</span><span style="COLOR: #800080">%w</span><span style="COLOR: #000000">(add聽(tīng)show)<br />聽(tīng)聽(tīng)end<br /><br />聽(tīng)聽(tīng)def聽(tīng)groups<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)</span><span style="COLOR: #800080">%w</span><span style="COLOR: #000000">(users)<br />聽(tīng)聽(tīng)end<br />end</span></div><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">class聽(tīng)TestController聽(tīng)</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">聽(tīng)ApplicationController<br />聽(tīng)聽(tīng)def聽(tīng)test1<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)check_role聽(tīng)</span><span style="COLOR: #000000">:</span><span style="COLOR: #000000">add<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)render_text聽(tīng)</span><span style="FONT-WEIGHT: bold; COLOR: #000000">"</span><span style="FONT-WEIGHT: bold; COLOR: #000000">OK</span><span style="FONT-WEIGHT: bold; COLOR: #000000">"</span><span style="COLOR: #000000"><br />聽(tīng)聽(tīng)end<br /><br />聽(tīng)聽(tīng)def聽(tīng)test2<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)check_role聽(tīng)</span><span style="COLOR: #000000">:</span><span style="COLOR: #000000">add<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)check_group聽(tīng)</span><span style="COLOR: #000000">:</span><span style="COLOR: #000000">users<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)render_text聽(tīng)</span><span style="FONT-WEIGHT: bold; COLOR: #000000">"</span><span style="FONT-WEIGHT: bold; COLOR: #000000">OK</span><span style="FONT-WEIGHT: bold; COLOR: #000000">"</span><span style="COLOR: #000000"><br />聽(tīng)聽(tīng)end<br /><br />聽(tīng)聽(tīng)def聽(tīng)test3<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)check_groups聽(tīng)</span><span style="COLOR: #000000">:</span><span style="COLOR: #000000">admin</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">聽(tīng)</span><span style="COLOR: #000000">:</span><span style="COLOR: #000000">users<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)render_text聽(tīng)</span><span style="FONT-WEIGHT: bold; COLOR: #000000">"</span><span style="FONT-WEIGHT: bold; COLOR: #000000">OK</span><span style="FONT-WEIGHT: bold; COLOR: #000000">"</span><span style="COLOR: #000000"><br />聽(tīng)聽(tīng)end<br /><br />聽(tīng)聽(tīng)def聽(tīng)test4<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)check_roles聽(tīng)</span><span style="COLOR: #000000">:</span><span style="COLOR: #000000">add</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">聽(tīng)</span><span style="COLOR: #000000">:</span><span style="COLOR: #000000">remove<br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)render_text聽(tīng)</span><span style="FONT-WEIGHT: bold; COLOR: #000000">"</span><span style="FONT-WEIGHT: bold; COLOR: #000000">OK</span><span style="FONT-WEIGHT: bold; COLOR: #000000">"</span><span style="COLOR: #000000"><br />聽(tīng)聽(tīng)end<br />end</span></div><br />鍏朵腑錛宼est1銆乼est2閮戒細(xì)鎴愬姛錛岃宼est3鍜宼est4鍒欎細(xì)澶辮觸鏄劇ず寮傚父錛屽彧闇瑕佸鐞唕escue_action鎶婂畠淇敼涓鴻嚜宸辯殑鏄劇ず欏甸潰鍗沖彲銆?img src ="http://m.shnenglu.com/cpunion/aggbug/6790.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/cpunion/" target="_blank">qiezi</a> 2006-05-08 21:30 <a href="http://m.shnenglu.com/cpunion/archive/2006/05/08/6790.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>[RoR] Login Engine琛ヤ竵http://m.shnenglu.com/cpunion/archive/2006/05/08/6778.htmlqieziqieziMon, 08 May 2006 13:13:00 GMThttp://m.shnenglu.com/cpunion/archive/2006/05/08/6778.htmlhttp://m.shnenglu.com/cpunion/comments/6778.htmlhttp://m.shnenglu.com/cpunion/archive/2006/05/08/6778.html#Feedback0http://m.shnenglu.com/cpunion/comments/commentRss/6778.htmlhttp://m.shnenglu.com/cpunion/services/trackbacks/6778.htmlLogin Engine鏄潪甯稿ソ鐢ㄧ殑涓涓櫥褰昬ngine錛屼笉榪囦篃鏈変釜緙虹偣錛屽畠鎶婄敤鎴蜂俊鎭紦瀛樺湪session閲屻傚鏋滅敤鎴鋒瘡嬈′慨鏀瑰畬鑷繁鐨勮祫鏂欙紝閮芥妸session鏇存柊鐨勮瘽錛岃嚜鐒舵槸涓嶄細(xì)鏈変粈涔堟暟鎹笉鍚屾鐨勯棶棰樸備笉榪囪瘯鎯寵繖鏍蜂竴縐嶆儏鍐碉細(xì)

1銆佺敤鎴稟鐧誨綍錛涚敤鎴稟鐨勪俊鎭皢淇濆瓨鍦╯ession[:user]閲屻?br />2銆佺鐞嗗憳鎿嶄綔鐢ㄦ埛A錛屼慨鏀圭敤鎴稟鐨勮祫鏂欏茍淇濆瓨銆?br />3銆佺敤鎴稟鍒鋒柊欏甸潰銆?/p>

濡傛灉鏄劇ず鐢ㄦ埛璧勬枡鏄粠session[:user]璇誨彇鐨勮瘽錛屾樉鐒剁敤鎴稟鐪嬪埌鐨勬槸鑰佺殑璧勬枡銆?br />
姝g‘鐨勫仛娉曟槸綆$悊鍛樹(shù)慨鏀圭敤鎴瘋祫鏂欎互鍚庯紝鎶婄敤鎴穝ession閲岀殑鍐呭涔熸洿鏂幫紝褰撶劧榪欎釜瀹炴柦璧鋒潵鏈変簺鍥伴毦錛岀洰鍓嶇湅鏉ユ棤娉曠敱鐢ㄦ埛ID鑾峰緱瀵瑰簲鐨剆ession銆?br />
鏈夋湅鍙嬭session閲屼笉搴旇緙撳瓨鐢ㄦ埛淇℃伅錛岃屽簲鍙繚瀛樼敤鎴稩D銆傝繖鏄紜殑錛岃繖鏍峰彲浠ヨВ鍐充笂闈㈢殑闂錛屼笉榪囧甫鏉ョ殑闂鏄瘡嬈¢兘瑕佷粠鏁版嵁搴撴煡璇€?br />
濡傛灉姣忔鍒鋒柊欏甸潰閮戒粠鏁版嵁搴撻噸鏂拌鍙栫敤鎴蜂俊鎭紝瀵規(guī)ц兘褰卞搷鏄緢澶х殑銆傝瘯鎯充竴涓嬬敤鎴鋒鍦ㄦ祻瑙堜竴涓鍧涚殑甯栧瓙鍒楄〃錛岃繖涓〉闈㈠彲鑳芥墍鏈夌敤鎴風(fēng)湅璧鋒潵閮芥槸涓鏍風(fēng)殑錛屽敮涓涓嶄竴鏍風(fēng)殑鍦版柟鏄笂闈㈢敤鎴蜂俊鎭殑鏄劇ず銆傜敱浜庡ぇ閮ㄥ垎鍐呭閮戒竴鏍鳳紝鍙互浣跨敤緙撳瓨鍔犲揩嫻忚閫熷害銆備笉榪囧嵈鐢變簬session閲屽彧淇濆瓨?shù)簡(jiǎn)鐢ㄦ埛ID錛屼笉寰椾笉璇誨彇鏁版嵁搴撴潵鑾峰緱鐢ㄦ埛淇℃伅錛岃繖鏍峰氨鎶婇熷害鍙堟嫋鎱簡(jiǎn)銆?br />
鎵浠ュ簲璇ユ妸鐢ㄦ埛淇℃伅緙撳瓨璧鋒潵錛屼絾瑕佷繚璇佸畠鑳藉強(qiáng)鏃舵洿鏂般傛柟娉曡嚜宸卞仛涓涓紦瀛樼鐞嗗櫒錛岃兘鏍規(guī)嵁鐢ㄦ埛ID寰楀埌鐢ㄦ埛淇℃伅錛屼篃鑳介殢鏃舵洿鏂板畠銆?br />
瀛︾潃ActionController::Caching鍋氫簡(jiǎn)涓涓猆serManager錛屽畠鍙互鏍規(guī)嵁綰跨▼閰嶇疆鏉ヨ嚜鍔ㄥ紑鍏充簰鏂ュ櫒錛?br />(/vender/plugins/login_engine/lib/login_engine/user_management.rb)

module聽(tīng)UserManagement聽(tīng) # :nodoc:
聽(tīng)聽(tīng)class聽(tīng)UnthreadedUserManager聽(tīng) # :nodoc:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)initialize聽(tīng) # :nodoc:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) @users 聽(tīng) = 聽(tīng){}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)get(user_id)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@users [user_id]
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)set(user_id
, 聽(tīng)user)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@users [user_id]聽(tīng) = 聽(tīng)user
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)
聽(tīng)聽(tīng)module聽(tīng)ThreadSafety聽(tīng)
# :nodoc:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)get(user_id)聽(tīng) # :nodoc:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) @mutex . synchronize聽(tīng){聽(tīng)super聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)set(user_id
, 聽(tīng)user)聽(tīng) # :nodoc:
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) @mutex . synchronize聽(tīng){聽(tīng)super聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)
聽(tīng)聽(tīng)class聽(tīng)UserManager聽(tīng)
< 聽(tīng)UnthreadedUserManager
聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)initialize
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)super
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
if 聽(tīng)ActionController :: Base . allow_concurrency
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@mutex 聽(tīng) = 聽(tīng)Mutex . new
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)UserManager
. send ( : include , 聽(tīng)ThreadSafety)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)
聽(tīng)聽(tīng)@
@user_manager 聽(tīng) = 聽(tīng)UserManagement :: UserManager . new
聽(tīng)聽(tīng)
聽(tīng)聽(tīng)def聽(tīng)set_current_user(user)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
return 聽(tīng)session[ : user_id]聽(tīng) = 聽(tīng)nil聽(tīng) if 聽(tīng)user . nil ?
聽(tīng)聽(tīng)聽(tīng)聽(tīng)session[
: user_id]聽(tīng) = 聽(tīng)user . id
聽(tīng)聽(tīng)聽(tīng)聽(tīng)cache_user(user)
聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)
聽(tīng)聽(tīng)def聽(tīng)current_user
聽(tīng)聽(tīng)聽(tīng)聽(tīng)get_user(session[
: user_id])
聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)
聽(tīng)聽(tīng)def聽(tīng)cache_user(user)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
return 聽(tīng) if 聽(tīng)user . nil ?
聽(tīng)聽(tīng)聽(tīng)聽(tīng)@
@user_manager . set(user . id , 聽(tīng)user)
聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)
聽(tīng)聽(tīng)def聽(tīng)get_user(user_id)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)@
@user_manager . get(user_id)
聽(tīng)聽(tīng)end
end聽(tīng)聽(tīng)

淇敼(/verdor/plugins/login_engine/lib/login_engine.rb)錛?br />
#.
require
聽(tīng)'login_engine/user_management'

module聽(tīng)LoginEngine
聽(tīng)聽(tīng)include聽(tīng)UserManagement
聽(tīng)聽(tīng)
#.
end

鍔犲叆涓婇潰鍔犵矖鐨?琛屻?br />
淇敼(/verdor/plugins/login_engine/lib/login_engine/authenticated_system.rb)錛屾妸session[:user]鏇挎崲涓簊ession[:user_id]銆?br />
淇敼(/verdor/plugins/login_engine/app/controllers/user_controller.rb):

聽(tīng)聽(tīng)def聽(tīng)login
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
return聽(tīng)if聽(tīng)generate_blank
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@user聽(tīng)=聽(tīng)User.new(params[:user])
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
if聽(tīng)user聽(tīng)=聽(tīng)User.authenticate(params[:user][:login],聽(tīng)params[:user][:password])
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)user
.logged_in_at聽(tīng)=聽(tīng)Time.now
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)user
.save
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)set_current_user(user)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)flash[
:notice]聽(tīng)=聽(tīng)"Login聽(tīng)successful"
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)redirect_to_stored_or_default聽(tīng)
:action聽(tīng)=>聽(tīng)'home'
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
else
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@login聽(tīng)=聽(tīng)params[:user][:login]
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)flash
.now[:warning]聽(tīng)=聽(tīng)'Login聽(tīng)unsuccessful'
聽(tīng)聽(tīng)聽(tīng)聽(tīng)end
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)logout
聽(tīng)聽(tīng)聽(tīng)聽(tīng)set_current_user(nil)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)redirect_to聽(tīng)
:action聽(tīng)=>聽(tīng)'login'
聽(tīng)聽(tīng)end

聽(tīng)聽(tīng)def聽(tīng)get_user_to_act_on
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
@user聽(tīng)=聽(tīng)current_user
聽(tīng)聽(tīng)end

綆鍗曟祴璇曪細(xì)

require聽(tīng)'login_engine'

class聽(tīng)ApplicationController聽(tīng)
<聽(tīng)ActionController::Base
聽(tīng)聽(tīng)include聽(tīng)LoginEngine
聽(tīng)聽(tīng)
聽(tīng)聽(tīng)helper聽(tīng)
:user
聽(tīng)聽(tīng)model聽(tīng)
:user
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)before_filter聽(tīng)
:login_required
end

class聽(tīng)ShowController聽(tīng)<聽(tīng)ApplicationController
聽(tīng)聽(tīng)def聽(tīng)show
聽(tīng)聽(tīng)聽(tīng)聽(tīng)render_text聽(tīng)"User聽(tīng)name:聽(tīng)#{current_user.first_name}"
聽(tīng)聽(tīng)end
end

class聽(tīng)AdminController聽(tīng)<聽(tīng)ApplicationController
聽(tīng)聽(tīng)def聽(tīng)edit
聽(tīng)聽(tīng)聽(tīng)聽(tīng)user聽(tīng)
=聽(tīng)User.find(params[:id])
聽(tīng)聽(tīng)聽(tīng)聽(tīng)user
.update_attributes(:first_name聽(tīng)=>聽(tīng)params[:name])
聽(tīng)聽(tīng)聽(tīng)聽(tīng)cache_user(user)
聽(tīng)聽(tīng)聽(tīng) render_text "User name: #{user.first_name}"
聽(tīng)聽(tīng)end
end

涓涓畝鍗曠殑妯℃嫙錛?br />1銆佺敤鎴稟浠嶪E鐧誨綍錛岃闂?show/show錛屽皢鏄劇ず鐢ㄦ埛鐨勫悕瀛椼?br />2銆佺鐞嗗憳?shù)粠FF鐧誨綍錛岃闂?show/show錛屽皢鏄劇ず綆$悊鍛樺悕瀛椼?br />3銆佺鐞嗗憳璁塊棶/show/show/2?name=hello錛屽叾涓?鏄敤鎴稟鐨処D銆傝繖灝嗘妸鐢ㄦ埛A鐨勫悕瀛椾慨鏀逛負(fù)hello銆?br />4銆佺敤鎴稟鍒鋒柊欏甸潰錛屽彲浠ョ湅鍒版樉紺虹殑鐢ㄦ埛鍚嶅瓧宸茬粡鍙戠敓鍙樺寲銆?br />
浠ヤ笂榪囩▼璇磋繖涓慨鏀瑰凡緇忚揪鍒扮洰鐨勩傚疄鐜拌繖涓姛鑳藉茍涓嶉毦錛屼富瑕佹槸涓轟簡(jiǎn)淇濈暀Login Engine鍘熸湁鐨勫姛鑳戒笉鍙樸?br />
淇敼鍚庣殑浠g爜錛?br />m.shnenglu.com/Files/cpunion/login_engine.rar

qiezi 2006-05-08 21:13 鍙戣〃璇勮
]]>
Ruby on Rails 涓枃緇?/title><link>http://m.shnenglu.com/cpunion/archive/2006/04/24/6140.html</link><dc:creator>qiezi</dc:creator><author>qiezi</author><pubDate>Mon, 24 Apr 2006 02:25:00 GMT</pubDate><guid>http://m.shnenglu.com/cpunion/archive/2006/04/24/6140.html</guid><wfw:comment>http://m.shnenglu.com/cpunion/comments/6140.html</wfw:comment><comments>http://m.shnenglu.com/cpunion/archive/2006/04/24/6140.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/cpunion/comments/commentRss/6140.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/cpunion/services/trackbacks/6140.html</trackback:ping><description><![CDATA[<table style="BORDER-RIGHT: #aa0033 1px solid; BORDER-TOP: #aa0033 1px solid; FONT-SIZE: small; BORDER-LEFT: #aa0033 1px solid; BORDER-BOTTOM: #aa0033 1px solid" align="center"> <tbody> <tr> <td rowspan="3"> <img height="58" alt="Google Groups" src="http://groups.google.com/groups/img/groups_medium.gif" width="150" /> </td> <td align="middle" colspan="2"> <b>Subscribe to Ruby on Rails 涓枃緇?/b> </td> </tr> <form action="http://groups.google.com/group/railscn/boxsubscribe"> <tr> <td>Email: <input name="email" /></td> <td> <table style="BORDER-RIGHT: #ffcc33 2px outset; PADDING-RIGHT: 2px; BORDER-TOP: #ffcc33 2px outset; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; BORDER-LEFT: #ffcc33 2px outset; PADDING-TOP: 2px; BORDER-BOTTOM: #ffcc33 2px outset; BACKGROUND-COLOR: #ffcc33"> <tbody> <tr> <td> <input type="submit" value="Subscribe" name="sub" /> </td> </tr> </tbody> </table> </td> </tr> </form> <tr> <td align="middle" colspan="2"> <a >Browse Archives</a> at <a >groups.google.com</a></td> </tr> </tbody> </table> <br />閭歡鍒楄〃浜ゆ祦鏂逛究浜涳紝嬈㈣繋澶у璁㈤槄銆?br /><br />娉ㄦ剰錛?br />1銆佷笉瑕佷嬌鐢ㄩ偖浠惰嚜鍔ㄥ洖澶嶅姛鑳姐?br />2銆佷笉瑕佷嬌鐢ㄧ鍚嶃?br />3銆佸洖澶嶉偖浠舵敞鎰忚鍓紩鐢ㄣ?br />4銆佷嬌鐢ㄦ枃鏈偖浠躲?img src ="http://m.shnenglu.com/cpunion/aggbug/6140.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/cpunion/" target="_blank">qiezi</a> 2006-04-24 10:25 <a href="http://m.shnenglu.com/cpunion/archive/2006/04/24/6140.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Groovy on Rails 0.1鍙戝竷http://m.shnenglu.com/cpunion/archive/2006/04/07/5141.htmlqieziqieziFri, 07 Apr 2006 08:59:00 GMThttp://m.shnenglu.com/cpunion/archive/2006/04/07/5141.htmlhttp://m.shnenglu.com/cpunion/comments/5141.htmlhttp://m.shnenglu.com/cpunion/archive/2006/04/07/5141.html#Feedback0http://m.shnenglu.com/cpunion/comments/commentRss/5141.htmlhttp://m.shnenglu.com/cpunion/services/trackbacks/5141.html
鍦╓INDOWS涓嬫墽琛岋紝閬囧埌涓皬BUG錛実rails.bat絎?琛岋細(xì)if "%GRAILS_HOME"=="" goto grailsHomeNotSet鏄敊璇殑錛屾敼鎴恑f "%GRAILS_HOME%"=="" goto grailsHomeNotSet灝卞彲浠ヤ簡(jiǎn)銆傚悗闈篃鏈夌偣灝忛棶棰橈紝騫茶剢鍦↙INUX涓嬫祴璇曘?br />
鐓х潃Quick Start鍋氫簡(jiǎn)涓涓嬶紝榪樼畻欏哄埄錛屼笉榪囦緥瀛愭庝箞鍙粰浜?jiǎn)涓猯ist鍛紵鎬庝箞涔熷緱鎶奵reate/update/delete緇欏畬鎴愬槢銆?br />
鐚滅潃鍐欎簡(jiǎn)涓猚reate:

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)@Property聽(tīng)create聽(tīng)=聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)[聽(tīng)post聽(tīng):聽(tīng)
new聽(tīng)Post()聽(tīng)]
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)@Property聽(tīng)save聽(tīng)
=聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
new聽(tīng)Post(params).save()
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)redirect(action:list)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}

鎬庝箞瀛樿繘鍘葷殑涓嶆槸鎴戦偅涓瓧絎︿覆錛岃屾槸[Ljava.lang.String;@18b5a73鍛€傘?br />
鍙堢湅浜?jiǎn)涓嬫枃妗eQ屽湪controller閲岄潰鏄繖涔堢敤鐨勶細(xì)

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)@Property聽(tīng)save聽(tīng)=聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)post聽(tīng)
=聽(tīng)new聽(tīng)Post()
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)post.properties聽(tīng)
=聽(tīng)params
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)post.save()
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)redirect(action:list)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}

鍏跺畠閮藉緢鐩鎬技錛?br />
class聽(tīng)PostController聽(tīng){

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)@Property聽(tīng)index聽(tīng)
=聽(tīng){聽(tīng)redirect(action:list)聽(tīng)}

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)@Property聽(tīng)list聽(tīng)
=聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)[聽(tīng)postList聽(tīng):聽(tīng)Post.list()聽(tīng)]

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)@Property聽(tīng)create聽(tīng)
=聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)[聽(tīng)post聽(tīng):聽(tīng)
new聽(tīng)Post()聽(tīng)]
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)@Property聽(tīng)save聽(tīng)
=聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)post聽(tīng)
=聽(tīng)new聽(tīng)Post()
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)post.properties聽(tīng)
=聽(tīng)params
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)post.save()
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)redirect(action:list)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)@Property聽(tīng)show聽(tīng)
=聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)[聽(tīng)post聽(tīng):聽(tīng)Post.
get(params['id'])聽(tīng)]
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)@Property聽(tīng)delete聽(tīng)
=聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)Post.
get(params['id']).delete()
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)redirect(action:list)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)@Property聽(tīng)edit聽(tīng)
=聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)[聽(tīng)post聽(tīng):聽(tīng)Post.
get(params['id'])聽(tīng)]
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)@Property聽(tīng)update聽(tīng)
=聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)post聽(tīng)
=聽(tīng)Post.get(params['id'])
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)post.properties聽(tīng)
=聽(tīng)params
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)post.save()
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)redirect(action:list)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
}

璇硶涓婃瘮RoR紼嶉夯鐑?chǔ)鐐广?br />
鎺ョ潃嫻嬭瘯涓涓嬫煡璇細(xì)

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)@Property聽(tīng)list聽(tīng)=聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)title聽(tīng)
=聽(tīng)params['title']
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)body聽(tīng)
=聽(tīng)params['body']
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)postList
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)def聽(tīng)c聽(tīng)
=聽(tīng)Post.createCriteria()

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
//if聽(tīng)(title聽(tīng)!=聽(tīng)null聽(tīng)&&聽(tīng)title聽(tīng)!=聽(tīng)""聽(tīng)&&聽(tīng)body聽(tīng)!=聽(tīng)null聽(tīng)&&聽(tīng)body聽(tīng)!=聽(tīng)"")
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)if聽(tīng)(title聽(tīng)&&聽(tīng)body)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)postList聽(tīng)
=聽(tīng)c{
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)like(
"title",聽(tīng)"%"聽(tīng)+聽(tīng)title聽(tīng)+聽(tīng)"%")
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)like(
"body",聽(tīng)"%"聽(tīng)+聽(tīng)body聽(tīng)+聽(tīng)"%")
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
else聽(tīng)if聽(tīng)(title)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)postList聽(tīng)
=聽(tīng)c{
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)like(
"title",聽(tīng)"%"聽(tīng)+聽(tīng)+聽(tīng)title聽(tīng)+聽(tīng)"%")
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
else聽(tīng)if聽(tīng)(body)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)postList聽(tīng)
=聽(tīng)c{
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)like(
"body",聽(tīng)"%"聽(tīng)+聽(tīng)body聽(tīng)+聽(tīng)"%")
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
else
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)postList聽(tīng)
=聽(tīng)Post.list()

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)[聽(tīng)postList聽(tīng):聽(tīng)postList,聽(tīng)post聽(tīng):聽(tīng)
new聽(tīng)Post()聽(tīng)]
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}

list.gsp閲岄潰娣誨姞錛?br />
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)<g:form聽(tīng)action="list"聽(tīng)method="post">
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
<div聽(tīng)class="dialog">
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
<table>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
<tr聽(tīng)class='prop'>
聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) <
td聽(tīng)valign='top'聽(tīng)style='text-align:left;'聽(tīng)width='20%'>
聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) <
label聽(tīng)for='title'>Title:</label>
聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) </
td>
聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) <
td聽(tīng)valign='top'聽(tīng)style='text-align:left;'聽(tīng)width='80%'
聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) class='${hasErrors(bean:post,field:'title','errors')}'>
聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) <
input聽(tīng)type='text'聽(tīng)name='title'聽(tīng)value='${post?.title}'聽(tīng)/>
聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) </
td>
聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) </
tr>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
<tr聽(tīng)class='prop'>
聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) <
td聽(tīng)valign='top'聽(tīng)style='text-align:left;'聽(tīng)width='20%'>
聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) <
label聽(tīng)for='body'>Body:</label>
聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) </
td>
聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) <
td聽(tīng)valign='top'聽(tīng)style='text-align:left;'聽(tīng)width='80%'
聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) class
='${hasErrors(bean:post,field:'body','errors')}'>
聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) <
input聽(tīng)type='text'聽(tīng)name='body'聽(tīng)value='${post?.body}'聽(tīng)/>
聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) </
td>
聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) </
tr>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
</table>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
</div>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
<div聽(tīng)class="buttons">
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
<span聽(tīng)class="formButton">
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
<input聽(tīng)type="submit"聽(tīng)value="Search"></input>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
</span>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
</div>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
</g:form>

groovy鍐欎唬鐮佹尯鐑?chǔ)鐨勫Q屽眬閮ㄥ彉閲忎篃瑕乨ef鏉ュ畾涔夛紵涓嶅畾涔夊氨鎻愮ず璇ュ彉閲忎笉鏄璞$殑瀛楁錛岃窡寰堝鑴氭湰璇█閮戒笉涓鏍楓傚鏋滀粠java涓婅漿榪囨潵錛屼細(xì)瑙夊緱榪樻槸鎸虹畝媧佺殑銆?br />
鍊熷姪spring銆乭ibernate錛孏rails鎵鍋氱殑灝辨槸鏁村悎錛実roovy榪欎釜璇█濂藉儚騫舵病鏈夌壒鍒嚭浼楃殑鍦版柟錛屽ぇ閮ㄥ垎涓滆タ鍦ㄥ叾瀹冭剼鏈璦閲岄潰閮借兘鐪嬪埌銆傛垜瑙夊緱ruby鏇村鏄撴墿鍏咃紝鏇磋嚜鐢便侴rails瑕佹兂鎴愬姛錛岄櫎闈炲湪鏁堢巼涓婂ぇ騫呭害棰嗗厛錛屽氨嫻嬭瘯鏉ョ湅錛屽茍娌℃湁瑙夊緱寰堝揩錛屽畠涔熸病鎻愪緵涓瘎嫻嬪伐鍏楓傛嵁璇磖uby2.0涔熻閲嶅啓铏氭嫙鏈猴紝濡傛灉ruby鍙槸紼嶆參涓浜涳紝鑷劧榪樻槸閫塕oR姣旇緝濂姐?br />

qiezi 2006-04-07 16:59 鍙戣〃璇勮
]]>
rails鐩稿叧閾炬帴鏀墮泦http://m.shnenglu.com/cpunion/archive/2006/03/23/4489.htmlqieziqieziThu, 23 Mar 2006 04:53:00 GMThttp://m.shnenglu.com/cpunion/archive/2006/03/23/4489.htmlhttp://m.shnenglu.com/cpunion/comments/4489.htmlhttp://m.shnenglu.com/cpunion/archive/2006/03/23/4489.html#Feedback0http://m.shnenglu.com/cpunion/comments/commentRss/4489.htmlhttp://m.shnenglu.com/cpunion/services/trackbacks/4489.html
鎵╁睍ActiveRecord紺轟緥錛?br />http://wiki.rubyonrails.com/rails/pages/ExtendingActiveRecordExample

澧炲姞created_by鍜寀pdated_by欖旀湳瀛楁錛?br />http://wiki.rubyonrails.com/rails/pages/Howto+Add+created_by+and+updated_by

宓屽闆嗗悎錛堟爲(wèi)錛夛細(xì)
http://threebit.net/tutorials/nestedset/tutorial1.html
http://api.rubyonrails.com/classes/ActiveRecord/Acts/NestedSet/ClassMethods.html

acts_as_threaded鎻掍歡婕旂ず錛堝彲鍒朵綔璁哄潧銆侀偖浠剁嚎绱級(jí)錛?br />http://www.railtie.net/plugins/acts_as_threaded/threaded.swf


qiezi 2006-03-23 12:53 鍙戣〃璇勮
]]>
瀛︿範(fàn)Ruby鐨勪竴鐐逛綋浼?/title><link>http://m.shnenglu.com/cpunion/archive/2005/09/30/507.html</link><dc:creator>qiezi</dc:creator><author>qiezi</author><pubDate>Fri, 30 Sep 2005 04:12:00 GMT</pubDate><guid>http://m.shnenglu.com/cpunion/archive/2005/09/30/507.html</guid><wfw:comment>http://m.shnenglu.com/cpunion/comments/507.html</wfw:comment><comments>http://m.shnenglu.com/cpunion/archive/2005/09/30/507.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/cpunion/comments/commentRss/507.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/cpunion/services/trackbacks/507.html</trackback:ping><description><![CDATA[<P>浠呬粎鏄釜浜虹殑涓鐐逛綋浼?xì)銆?BR><BR>棣栧厛瀹冨拰python閮藉睘浜庡姩鎬佽В閲婂瀷鑴氭湰璇█錛岄櫎姝や箣澶栵紝鏈夊緢澶氫笉鍚屻?BR><BR>python鏄竴涓函綺圭殑鑴氭湰璇█錛屼互鏄撳鏄撶敤涓轟富錛孯uby鏇村鏉備竴浜涳紝瀹冪殑璇硶涓婃洿宕囧皻綆媧侊紝鍦ㄨ娉曞拰璇箟涓婃瘮python瑕佷弗鏍煎緱澶氥傝櫧鐒秔ython瑕佹眰浠ョ緝榪戞潵鎺у埗鏍煎紡錛屼絾闄や簡(jiǎn)榪欑偣浠ュ錛屽叾瀹冩柟闈uby閮芥瘮瀹冭涓ユ牸錛屾煇浜涙柟闈㈠彲浠ヨ涓篟uby鈥滄洿鍍忔槸涓闂ㄧ湡姝g殑璇█鈥濄?BR><BR><BR><BR>鍒氬紑濮嬪錛屾參鎱㈡葷粨鍚с?BR><BR>Ruby on Rails涔熺収鐫鍋氫簡(jiǎn)涓鎶婏紝鏋滅劧寰堥叿錛屽彧鏄湁浜涙暀紼嬪拰鐩墠鐨勭増鏈笉涓鑷淬?BR><BR>瀵筊uby榪樹(shù)笉鐔燂紝瑕佸仛欏圭洰涔熷彧濂藉厛瀛︿竴涓嬭璦浜?jiǎn)锛屽Ruby鎰熷叴瓚o紝涓鏄湅鍒頒簡(jiǎn)Ruby on Rails錛屽彟澶栧氨鏄湡鐨勫幓瀛︿範(fàn)鏃訛紝鎵嶅彂鐜板畠涓嶆槸鍙︿竴涓猵ython/js/vb/php絳夎剼鏈璦銆?/P><img src ="http://m.shnenglu.com/cpunion/aggbug/507.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/cpunion/" target="_blank">qiezi</a> 2005-09-30 12:12 <a href="http://m.shnenglu.com/cpunion/archive/2005/09/30/507.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Ruby瀛︿範(fàn)璧勬簮http://m.shnenglu.com/cpunion/archive/2005/09/28/477.htmlqieziqieziWed, 28 Sep 2005 13:12:00 GMThttp://m.shnenglu.com/cpunion/archive/2005/09/28/477.htmlhttp://m.shnenglu.com/cpunion/comments/477.htmlhttp://m.shnenglu.com/cpunion/archive/2005/09/28/477.html#Feedback0http://m.shnenglu.com/cpunion/comments/commentRss/477.htmlhttp://m.shnenglu.com/cpunion/services/trackbacks/477.html
  • Ruby瀹樻柟緗戠珯錛?A >www.ruby-lang.org
  • Ruby鍥藉唴涓枃绔欙細(xì)http://www.ruby-cn.org/
  • Ruby on Rails錛?A >http://www.rubyonrails.org/
  • Ajax on Rails錛?A >http://www.onlamp.com/lpt/a/5944
  • 聽(tīng)



    qiezi 2005-09-28 21:12 鍙戣〃璇勮
    ]]>
    久久久亚洲AV波多野结衣| 久久精品嫩草影院| 狠狠精品久久久无码中文字幕| 国产99久久久国产精品小说| 老男人久久青草av高清| 久久综合国产乱子伦精品免费| 99久久无色码中文字幕| 97超级碰碰碰碰久久久久| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 99久久国产主播综合精品| 色8激情欧美成人久久综合电| 日韩欧美亚洲综合久久 | 久久夜色精品国产噜噜亚洲a| 久久久无码一区二区三区| 久久久久亚洲AV成人网人人软件 | 国产精品久久免费| 久久99热这里只有精品66| 色综合久久中文综合网| 久久亚洲精品国产精品| 香蕉99久久国产综合精品宅男自 | 九九久久精品国产| 97久久综合精品久久久综合| 亚洲国产日韩欧美综合久久| 97久久综合精品久久久综合| 人妻少妇久久中文字幕| 成人午夜精品无码区久久| 亚洲国产精品成人AV无码久久综合影院 | 久久久无码精品亚洲日韩按摩 | 久久精品国产99久久久古代| 久久久99精品成人片中文字幕| 久久99精品国产99久久6男男| 天堂久久天堂AV色综合| 精品综合久久久久久97| 亚洲人成无码久久电影网站| 久久综合九色综合久99| 久久亚洲AV无码西西人体| 久久人人爽人爽人人爽av | 亚洲αv久久久噜噜噜噜噜| 久久久精品人妻一区二区三区蜜桃| 久久亚洲视频| 欧美精品乱码99久久蜜桃|