<td>
<%=link_to image_tag(phone.image, :class => 'list_image'), :controller => 'phones_feature_controller', :action => 'index', :id => phone.id %>
</td>
I want to have an image link to another controller. This link is in my index page and its controller is phone
. I have another controller phones_feature
. I want to have a link to phones_feature
's index page
my phones_feature_controller :
def index
@phones=Phone.find(params[:id])
respond_to do |format|
format.html # index.html.erb
format.json { render json: @phones }
end
end
You are adding controller to your controller name.
<%=link_to image_tag(phone.image, :class => 'list_image'),:controller => 'phones_feature', :action => 'index', :id=>phone.id %>
check url_for documentation
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.