2012-03-19 15 views
0

再書き込み撮影のポートフォリオサイトに指定されたパスにチョーク、およびURLは、フォーマットに従わなければならない:RSpecのは、レール3

[site].com/portfolio/[category]/[image] 

現在の実装と一致します。

[site] .comと[site] .com/portfolioはルートに解決する必要があります。私は私のヘッダー内のリンクを追加しました

root :to => 'portfolio#index' 

match '/portfolio', :to => 'portfolio#index' 

match '/portfolio/*category/*photo', :to => 'portfolio#photo' 
match '/portfolio/*category', :to => 'portfolio#photo' 

:私のルート・ファイルは以下の通りです

%li= link_to "Portfolio", root_path 

、これは正常に動作しますが、私が追加したとき:

%li= link_to "Editorial", portfolio_photo_path 

私のページには、罰金解決しますブラウザー内では、rspecは私の目を覚ます。以前に今も元気実行します最も単純なHTTPの成功のテストが返す:

1) PortfolioController GET 'index' returns http success 
Failure/Error: get 'index' 
ActionView::Template::Error: 
    undefined local variable or method `portfolio_photo_path' for #<#<Class:0x572d210>:0x5733d68> 
# ./app/views/layouts/_header.html.haml:7:in `_app_views_layouts__header_html_haml__420220390_28357236' 
# ./app/views/layouts/application.html.haml:10:in `_app_views_layouts_application_html_haml__156489427_30065868' 
# ./spec/controllers/portfolio_controller_spec.rb:8:in `block (3 levels) in <top (required)>' 

(私はルートを熊手とき、私は次の取得)

$ rake routes 
    root/         portfolio#index 
portfolio /portfolio(.:format)     portfolio#index 
      /portfolio/*category/*photo(.:format) portfolio#photo 
      /portfolio/*category(.:format)  portfolio#photo 
+0

私は豚です。私は、変数を取り込むために経路をグロブに使用しているので、それが窒息していると思われます。したがって、portfolio_photo_pathは実際にはどこにも行きません。私は何をする必要があるのか​​混乱していた。それは自動化の道ではない。別の方法でパスを動的に作成する必要があります。 コントローラーでredirect_toを使用すると、もう一度ブレークするのは面白いですが、おそらくここでは範囲外です。 – user1279629

答えて

0

上記のコメントでは、私は変数globbedルートを定義し、頭脳的に私はリンクを直接かつ動的に構築しなければならないと気付かなかった。

1

あなたは追加する必要があります「:として=>:ポートフォリオ」ステートメント:

match '/portfolio', :to => 'portfolio#index', :as => :portfolio