我的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