入れ子のリソースに関する問題について
蛇足感がありますが、ちょっと補足しておきます。
そもそも何が問題かというと、 Commentsコントローラが担当すべきCommentリソースの処理を、 Postsコントローラで書かなきゃいけないのが格好わるいのでなんとかしたい、という事なんです。
Child belongs_to
View上で階層関係になっているものを、フラットなController
蛇足感がありますが、ちょっと補足しておきます。
そもそも何が問題かというと、 Commentsコントローラが担当すべきCommentリソースの処理を、 Postsコントローラで書かなきゃいけないのが格好わるいのでなんとかしたい、という事なんです。
Child belongs_to
View上で階層関係になっているものを、フラットなController
[追記 2009.01.20
moroさんの記事を読んで、Cucumber wktk!と思っていたのでtry
http://d.h
atena.ne.j p/moro/200 81112/1226 486135
http://d.hatena.ne.j p/moro/200 81118/1226 977015
http://gist.github.c om/26024
こちらの導入手順を参考しました:
http://wik
ローカルには0.1.15を入れたのですが、念のため0.1.13で依存しているというgem:aslakh
1 gem sources -a http://gems.github.c om 2 sudo gem install aslakhelle soy-webrat
${RAILS_ROOT
1 require "webrat" 2 Webrat.configure do |config| 3 config.mod e = :rails 4 end
moroさんところのcucumberの構造辺りで紹介されているgeneratorでfeatureやstepsを生成:
1 $ ruby script/generate feature Product
moroさんのgistを下記に保存して使用し始めたのですが、
1 ${RAILS_ROOT}/features/ step_defin itions/web rat_ja_ste ps.rb
細かい仕様が変更されていました:
ディレクトリstep_defin
1 visit home_path 2 fill_in "Email", :with => "good@example.com"
またpendingされたstepには、下記のようにsnippetsが出力されて便利だなぁと思いました:
1 You can use these snippets to implement pending steps which have no step definition: 2 When /^パラメータを入力する product_co mment\[body\]=dummy comment!$/ do 3 end
http://mor
http://d.h
http://bar
Merbでは、URLとアクションのマッチングをconfig/rou
1 match(%r{^/gems/(.*)$}).to( 2 :controller=> 'gems', :action => 'show', :name => "[1]")
正規表現にマッチしたグループを、パラメータ側から"[1]"のように後方参照する事ができます。