Resources:
MySESRole:
Type: AWS::IAM::Role
Properties:
RoleName: MySESRole
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Action: "sts:AssumeRole"
Principal:
Service: ["ecs-tasks.amazonaws.com", "ecs.amazonaws.com"]
Effect: "Allow"
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonSESFullAccess
我的application.html.erb中有上述代码行。因此,当我在Rails应用程序中单击超链接<h1>List of products</h1>
<%= link_to 'Download as .xlsx', products_path(format: :xlsx) %>
时,会将我路由到"Download as .xlsx"
,该代码具有生成excel的代码。这对我来说非常合适。
现在,我想用引导按钮替换上面的超链接。因此,当我单击该按钮时,也需要同时路由到products_path
。
我该如何实现?请帮忙!
答案 0 :(得分:0)
<%= button_to "Download as .xlsx", products_path(format: :xlsx), :id => "my_id", :class=> "btn btn-default", :method => :get %>
您可以使用其他bootstrap button class使其更美观
添加:method => :get
,否则,button_to将生成一个form
,其方法设置为post
。
已更新:- 使其动态化
<%= link_to products_path(format: :xlsx) do%>
<button type="button" class="btn btn-primary">Download as xlsx</button>
<%end%>