現在表示されているレコードと同様のタグを持つすべてのレコードを検索しようとしています。私のコントローラーには:
def show
@tattoo =Tattoo.find(params[:id])
tags = @tattoo.style_list.join(", ")
@tattoos = Tattoo.tagged_with(tags, :any => true).limit(6)
end
(誰かがarraryのレコードの順序をランダム化する方法を教えてくれればボーナスポイント)私のビューは配列をループするだけです。
とにかく、ほとんどいつも動作しますが、時々壊れることに気づきました。トラブルシューティング中に、使用すると壊れることがわかりましたtagged_with("jesse smith", :any => true)
が、試してみると動作しtagged_with("jason stephan", :any => true)
ます。tagged_with("black ink", :any => true)
したがって、各用語にはスペースが含まれていますが、何らかの理由で「jessesmith」はアクションを強制終了します。
私のコンソールは、ルーティングエラーもあることを示しています:
ActionView::Template::Error (No route matches {:action=>"show", :controller=>"tattoos", :member_id=>nil, :id=>#<Tattoo id: 170, description: "", status: "approved", member_id: nil, created_at: "2011-10-25 23:08:17", updated_at: "2011-11-17 16:56:55", file_file_name: "starry-eyed-rabid-squirrelweb.jpg", file_content_type: "image/jpeg", file_file_size: 294782, file_updated_at: "2011-10-25 23:08:17", album_id: nil, position: 116, favorite_count: 0, share_count: 1, file_remote_url: "http://www.jessesmithtattoos.com/wp-content/gallery...">}):
22: <ol class="small_tattoos">
23: <% @tattoos.each do |t| %>
24: <li>
25: <%= link_to image_tag(t.file.url(:tiny),:alt=>"#{t.style_list}, rtattoos, tattoos"), member_tattoo_path(t.member, t) %>
26: </li>
27: <% end %>
28: </ol>
app/views/index/show.html.erb:25:in `block (2 levels) in _app_views_index_show_html_erb___1839804211534816245_69842632179360__4333294961394575926'
app/views/index/show.html.erb:23:in `block in _app_views_index_show_html_erb___1839804211534816245_69842632179360__4333294961394575926'
app/views/index/show.html.erb:11:in `_app_views_index_show_html_erb___1839804211534816245_69842632179360__4333294961394575926'
では、なぜ1つの用語がルーティングエラーを引き起こし、他の用語は引き起こさないのでしょうか。