我正在使用 Rails 助手来生成按钮,并且我正在尝试使用按钮的 Twitter Bootstrap 样式来设置按钮的样式。我添加了带有 :html
的类选项。页面没有中断,但样式没有显示。
<%= button_to('Sign Up', new_user_registration_path, :html => {:class => 'btn.btn-large.btn-primary'}) %>
<%= button_to "Sign Up", user_omniauth_authorize_path(:facebook), :html => {:class => 'btn.btn-large.btn-primary'} %>
这是 facebook 按钮的页面源
<form action="/users/sign_up" class="button_to" method="post"><div><input html="{:class=>"btn.btn-large.btn-primary"}" type="submit" value="Sign Up" /><input name="authenticity_token" type="hidden" value="QIvZqd9BRV8TMspMvckAUjhC68nm3NTyQCxVRHFA4PE=" /></div></form>
<form action="/users/auth/facebook" class="button_to" method="post"><div><input html="{:class=>"btn.btn-large.btn-primary"}" type="submit" value="Sign Up" /><input name="authenticity_token" type="hidden" value="QIvZqd9BRV8TMspMvckAUjhC68nm3NTyQCxVRHFA4PE=" /></div></form>
知道我做错了什么吗?
最佳答案
你只需要:class => "foo"
设置按钮的类别,而不是 :html => { :class => "foo" }
.所以它应该是这样的:
<%= button_to('Sign Up', new_user_registration_path, :class => 'btn btn-large btn-primary') %>
这将生成您的大主按钮。
关于ruby-on-rails - 使用 Twitter Bootstrap 设计 Rails 按钮链接助手,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9952570/