【发布时间】:2014-09-10 21:23:20
【问题描述】:
我有以下 HTML 和 .erb 代码:
<button type="button" class="btn btn-default btn-lg"><%= link_to "Customer Information", customer_information_path %></button>
链接呈现正常,但单击时什么也不做。
这是我的路线文件:
devise_scope :user do
root :to => "devise/sessions#new"
end
get "hub" => "pages#hub"
get "customer_information" => "pages#customer_information"
这是我的页面控制器:
class PagesController < ApplicationController
def hub
end
def customer_information
end
end
代码不会抛出任何错误。
想法?
【问题讨论】:
-
app/views/pages/customer_information.html.erb有视图吗? -
您能否补充一点关于为什么需要按钮的信息?
-
是的,customer_information.html.erb 文件确实存在于我的视图中。
-
那么,是否有可能丢失按钮并将链接样式设置为按钮?
-
我暂时没有参考资料给你看,但是锚标签会将锚标签内的文本标记为超链接,所以点击锚标签外的按钮部分不会工作,因为按钮上没有链接。更多信息
anchor tag
标签: ruby-on-rails ruby controller routes link-to