2014-01-17 59 views
0

我有我的看法如下HTML标签类:条的Rails从button_to

 <%= button_to 'Check In', controller: "posts", action: :check_in, id: @post.id, :class => "btn", :style => "display:inline" %> 

出于某种原因,:类:风格不被呈现的HTML结束。我曾尝试将这个类和样式放在其他ERB标签上,并从那里获得渲染。他们为什么只在这个标签上被剥离?

回答

0

button_to(name = nil, options = nil, html_options = nil, &block)

因此,你需要用的选项和html_options属性哈希

<%= button_to 'Check In', { controller: "posts", action: :check_in, id: @post.id }, { :class => "btn", :style => "display:inline" } %>

0

许多标签助手需要HTML属性才能在:html键中。

<%= button_to 'Check In', controller: "posts", action: :check_in, id: @post.id, :html => {:class => "btn", :style => "display:inline"} %>