2014-01-17 58 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"} %>