MDA/MDD/TDD/DDD/DDDDDDD
          posts - 536, comments - 111, trackbacks - 0, articles - 0
            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          通常,更新操作在結(jié)束時(shí)會(huì)重定向到其它action。那么如何在重定向過(guò)程中保證狀態(tài)消息不會(huì)丟失呢?如果將狀態(tài)消息保存到成員變量中,會(huì)導(dǎo)致這一消息在 重定向后丟失。而使用session來(lái)作為保存機(jī)制雖然可行,但開(kāi)發(fā)人員必須在隨后執(zhí)行清理session這一很容易被遺漏的操作。因此,Rails提供 了flash作為解決方案。使用flash時(shí),消息首先被保存到session中,以便本次重定向可以使用。而在下一次重定向后,Rails會(huì)自動(dòng)在 session中清理該消息。從而有效地解決了更新操作的狀態(tài)信息在重定向時(shí)的保存問(wèn)題。
          http://www.infoq.com/cn/articles/rails-for-java-excerpt
          http://jbf034.javaeye.com/blog/222730

          posted @ 2010-02-15 18:34 leekiang 閱讀(272) | 評(píng)論 (0)編輯 收藏

          http://jbf034.javaeye.com/blog/222755

          posted @ 2010-02-15 18:34 leekiang 閱讀(272) | 評(píng)論 (0)編輯 收藏

          Java開(kāi)發(fā)者的Rails之路
          Rails for Java Developers

          posted @ 2010-02-15 03:19 leekiang 閱讀(250) | 評(píng)論 (0)編輯 收藏

          1,ORM已經(jīng)過(guò)時(shí)了http://www.javaeye.com/articles/2266
          ? http://codemonkeyism.com/orms/
          2,http://corte.si/posts/code/farewell-to-orms.html
          3,http://andyhu1007.javaeye.com/blog/636063
          http://blog.csdn.net/chelsea/archive/2009/12/28/5094652.aspx

          posted @ 2010-02-14 21:22 leekiang 閱讀(296) | 評(píng)論 (0)編輯 收藏


          至于easymock之外的選擇,我個(gè)人比較喜歡和推崇jmockit,mocito雖然也不錯(cuò)不過(guò)有了jmockit我就pass掉mockito了。
          只是每次看到項(xiàng)目代碼中,用easymock有record,replay卻不調(diào)用verify時(shí),就覺(jué)得郁悶。這樣的testcase,就算通過(guò)了,又能說(shuō)明什么?

          Mock通常很少考慮復(fù)用,每個(gè)mock對(duì)象通過(guò)都是遵循"just enough"原則,一般只適用于當(dāng)前測(cè)試方法。因此每個(gè)測(cè)試方法都必須實(shí)現(xiàn)自己的mock邏輯,當(dāng)然在同一個(gè)測(cè)試類(lèi)中還是可以有一些簡(jiǎn)單的初始化邏輯可以復(fù)用。
          stub則通常比較方便復(fù)用,尤其是一些通用的stub,比如jdbc連接之類(lèi)。spring框架就為此提供了大量的stub來(lái)方便測(cè)試,不過(guò)很遺憾的是,它的名字用錯(cuò)了:spring-mock
          mock和stub的最重要的區(qū)別:expectiation/期望。 對(duì)于mock來(lái)說(shuō),expectiation是重中之重:我們期待方法有沒(méi)有被調(diào)用,期待適當(dāng)?shù)膮?shù),期待調(diào)用的次數(shù),甚至期待多個(gè)mock之間的調(diào)用順序。所有的一切期待都是事先準(zhǔn)備好,在測(cè)試過(guò)程中和測(cè)試結(jié)束后驗(yàn)證是否和預(yù)期的一致。
          而對(duì)于stub,通常都不會(huì)關(guān)注expectiation


          easymock教程-mock和stub
          http://www.javaeye.com/topic/21630
          單元測(cè)試框架JMock與Mockito的用法比較
          http://javasee.iteye.com/blog/1000868
          http://hyjun.iteye.com/blog/337206
          單元測(cè)試mock:用JMockit寫(xiě)單元測(cè)試實(shí)例
          http://gojko.net/2009/10/23/mockito-in-six-easy-examples/

          posted @ 2010-02-14 21:20 leekiang 閱讀(311) | 評(píng)論 (0)編輯 收藏

          ?一個(gè)帶完整的RBAC授權(quán)系統(tǒng)的rails應(yīng)用
          http://www.javaeye.com/topic/215074

          RESTful_ACL


          declarative_authorization
          aegis
          cancan?????????? http://github.com/ryanb/cancan
          Authologic
          acl9???????????? http://github.com/be9/acl9
          role_requirement http://github.com/timcharper/role_requirement
          ActiveRbac


          restful_authentication
          1,ruby script/plugin install http://svn.techno-weenie.net/projects/plugins/restful_authentication/
          項(xiàng)目右鍵->rails 插件->資源庫(kù)里添加url:http://svn.techno-weenie.net/projects/plugins
          ->新插件里找到restful_authentication然后安裝
          2, ruby script/generate authenticated user sessions
          Right-click on your application in the projects pane and choose ?
          "Generate". In the dialog box that comes up, choose "authenticated" ?
          from the drop-down "Generator" menu near the top, and in the arguments ?
          field enter "user sessions" (without the quotes). Hit OK.
          ----------------------------------------------------------------------
          Don't forget to:

          Try these for some familiar login URLs if you like:

          map.activate '/activate/:activation_code', :controller => 'users', :action => 'activate', :activation_code => nil
          map.signup '/signup', :controller => 'users', :action => 'new'
          map.login '/login', :controller => 'sessions', :action => 'new'
          map.logout '/logout', :controller => 'sessions', :action => 'destroy'

          ----------------------------------------------------------------------
          ????? create? app/views/sessions
          ????? create? app/views/users
          ????? create? app/models/user.rb
          ????? create? app/controllers/sessions_controller.rb
          ????? create? app/controllers/users_controller.rb
          ????? create? lib/authenticated_system.rb
          ????? create? lib/authenticated_test_helper.rb
          ????? create? test/functional/sessions_controller_test.rb
          ????? create? test/functional/users_controller_test.rb
          ????? create? test/unit/user_test.rb
          ????? create? test/fixtures/users.yml
          ????? create? app/helpers/sessions_helper.rb
          ????? create? app/helpers/users_helper.rb
          ????? create? app/views/sessions/new.html.erb
          ????? create? app/views/users/new.html.erb
          ????? create? db/migrate/20100218184435_create_users.rb
          ????? route? map.resource :session
          ????? route? map.resources :users

          運(yùn)行測(cè)試時(shí)要把SessionsControllerTest和UsersControllerTest都改為繼承ActionController::TestCase,同時(shí)把fixtures :users注釋掉。

          要使用current_user和logged_in? helper方法的話(huà)要在ApplicationController里include?AuthenticatedSystem?

          resource與resources的區(qū)別見(jiàn)http://api.rubyonrails.org/classes/ActionController/Resources.html

          http://www.javaeye.com/topic/353831
          http://www.javaeye.com/topic/177508
          http://hideto.javaeye.com/blog/115157
          https://github.com/nakajima/roleful

          posted @ 2010-02-14 21:00 leekiang 閱讀(582) | 評(píng)論 (0)編輯 收藏

          http://www.pragprog.com/wikis/wiki/ChangesInRails23
          1, app/controllers下的application.rb is now application_controller.rb

          posted @ 2010-02-14 18:51 leekiang 閱讀(310) | 評(píng)論 (0)編輯 收藏

          1,http://kyoleelqh.javaeye.com/blog/169857

          2,Scribbish

          posted @ 2010-02-14 18:28 leekiang 閱讀(335) | 評(píng)論 (0)編輯 收藏

          http://m.onkey.org/2010/1/22/active-record-query-interface
          http://www.pragprog.com/wikis/wiki/ChangesInRails30

          posted @ 2010-02-14 17:58 leekiang 閱讀(271) | 評(píng)論 (0)編輯 收藏

          1,要在控制臺(tái)輸出log,在environment.rb里加:
          config.log_level = :debug
          config.logger = Logger.new(STDERR)
          同時(shí)在controller里加一行l(wèi)ogger.info 'test'
          成功了,但奇怪的是log_level設(shè)為dubug和info沒(méi)有區(qū)別

          2, http://wordpress.javaeye.com/blog/134544
          rails的日志文件存在于app/log下面。對(duì)于不同環(huán)境產(chǎn)生的日志內(nèi)容會(huì)有差別。development下會(huì)把每次對(duì)數(shù)據(jù)庫(kù)的訪(fǎng)問(wèn)代碼包含進(jìn)去,production會(huì)省略,不過(guò)也有很多的內(nèi)容。 如果只希望在production環(huán)境下,輸入少量的log, 則只需要在config/environments/production.rb中更改:
          config.log_level = :warn

          附帶log level:
          Rails可以通過(guò)選擇不同的log level來(lái)控制log文件的輸出,可以使用的log level有:debug, :info, :warn, :error, :fatal。 :debug level提供最詳細(xì)的log, 可以將每一條sql都記錄下來(lái)。:info level是production環(huán)境下的默認(rèn)設(shè)置,不會(huì)寫(xiě)出sql的執(zhí)行情況,但也會(huì)很詳細(xì),如果是ActiveMailer,它會(huì)記錄下每封信的內(nèi)容,Log文件內(nèi)容就是快速增長(zhǎng)。為了避免Log把空間塞滿(mǎn)的情況發(fā)生,要注意定期清除Log,另外是選擇:warn level等log level, 只記錄重要的信息.

          是否可以這么說(shuō):environment.rb對(duì)三個(gè)環(huán)境都生效,production.rb只對(duì)生產(chǎn)環(huán)境有效.


          3,在單元測(cè)試類(lèi)的方法里加了logger.dubug 'test',執(zhí)行測(cè)試時(shí)報(bào)錯(cuò),后改為
          RAILS_DEFAULT_LOGGER.debug 'test' 成功。


          Rails Logging Tips —— Rails寫(xiě)日志的提示http://www.cgpad.com/SPAN/articles_show/167
          http://hlee.javaeye.com/blog/358516

          posted @ 2010-02-14 02:24 leekiang 閱讀(824) | 評(píng)論 (0)編輯 收藏

          僅列出標(biāo)題
          共54頁(yè): First 上一頁(yè) 16 17 18 19 20 21 22 23 24 下一頁(yè) Last 
          主站蜘蛛池模板: 建平县| 本溪市| 慈利县| 临沭县| 南华县| 宿州市| 微博| 芜湖市| 望江县| 衡南县| 庄河市| 金寨县| 黔西| 枣庄市| 云浮市| 奉节县| 江川县| 垫江县| 沙坪坝区| 普兰店市| 登封市| 兴国县| 乌拉特前旗| 绥宁县| 灵川县| 宜丰县| 轮台县| 泾阳县| 太湖县| 星座| 兴山县| 滕州市| 屏山县| 临汾市| 卓尼县| 赤城县| 金寨县| 凤翔县| 泾川县| 鸡泽县| 阿拉善左旗|