新手问题 link_to 怎么嵌套其他的 dom 标签呢?

gefangshuai · 2013年11月20日 · 最后由 gefangshuai 回复于 2013年11月20日 · 2704 次阅读

比如这么一段 html

<a href="" class="btn btn-primary">
            <span class="glyphicon glyphicon-plus"></span>
            添加用户
</a> 

用 rails 的 link_to 怎么写?

http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to

<%= link_to(@profile) do %>
  <strong><%= @profile.name %></strong> -- <span>Check it out!</span>
<% end %>
# => <a href="/profiles/1">
       <strong>David</strong> -- <span>Check it out!</span>
     </a>

#1 楼 @Rei <%= link_to(root_path, options = {remote: true}) do%> 这里面怎么加 class="btn btn-primary"样式?加到 html_options 里不管用啊?

<%= link_to root_path, remote: true, class: "btn btn-primary" do%>

#5 楼 @Rei 不知道为什么,刚才也这么是过,就报错了,复制您的就好了,可能是我粗心了。真是感激不尽!!!

需要 登录 后方可回复, 如果你还没有账号请 注册新账号