Ruby on rails 我如何链接到我的家庭控制器.rb';什么是联络行动?
使用rails url helper,我如何链接到我的home_controller.rb的联系人操作Ruby on rails 我如何链接到我的家庭控制器.rb';什么是联络行动?,ruby-on-rails,Ruby On Rails,使用rails url helper,我如何链接到我的home_controller.rb的联系人操作 如何生成链接 怎么才能找到那条路 如何在操作中重定向到 谢谢你把这件事弄清楚 到目前为止,我的家庭控制器看起来像: resources :home do collection do get 'about' get 'contact' end end 您要查找的变量包括: contact_home_index_url 及 要查找这些路由(并查看所有
resources :home do
collection do
get 'about'
get 'contact'
end
end
您要查找的变量包括:
contact_home_index_url
及
要查找这些路由(并查看所有其他路由),请在命令行中使用rake routes
。在右边,您将看到动作和控制器;找到需要的行,取左边的变量,根据需要将\u path
或\u url
附加到末尾。对于嵌套管线,您需要提供一个参数,如:
new_event_boat_path(@event)
至于从控制器重定向,请尝试:
def redirect_sample
redirect_to contact_home_index_url
end
谢谢,奇怪的是它里面有“索引”!i、 e联系地址索引地址,我想应该是联系地址为什么会失败?其中article来自a.each循环,即@articles.each do | article |您需要使用指向helper的链接:
,但我只希望输出路径,而不是href标记.ah,然后使用
def redirect_sample
redirect_to contact_home_index_url
end