我的link_to是這樣的:控制器和動作不執行控制器代碼
<%= link_to image_tag(user_likes_selection.page_picture, :image_id =>
user_likes_selection.id, :controller => :preferences_controller,
:action => :checked_average_with_profile) %>
我的控制器,preferences_controller,有一個名爲checked_average_with_profile方法,其中,據我所知,是不是當我點擊圖片時被調用。
對從的link_to生成的HTML代碼是
<img>
<a href="/preferences"><img action="checked_average_with_profile" alt="Soul_surfer_film"
controller="preferences_controller" height="70%" image_id="3254"
src="/assets/soul_surfer_film.jpg" width="70%" /></a>
</img>
爲什麼單擊圖像時不執行的控制器編碼?
這看起來應該可行,但出於某種原因,當圖像被點擊時,我的應用程序重定向到root_url而不是preferences_url。另外,我的控制器指定的數據都沒有輸入到數據庫中。有什麼建議麼?它基本上看起來像以前一樣,但是這次它重新路由到root_url。 – dblarons 2013-03-08 08:24:44
實際上取決於'checked_average_with_profile'動作的內容。你可以在你的問題中加入嗎? – jvnill 2013-03-08 11:47:47