I am rendering a partial with 2 buttons and text and trying to put that couple of buttons on the same line as my text, using twitter bootstrap. Partial file:
<div class="well pull-right inline">
<% if logged_in? %>
Logged in as <%= session[:user] %>. <%= button_to 'Logout', logout_path, :class => "btn btn-danger", :form_class => "form-inline form-horizontal" %>
<% else %>
Welcome Guest! <%= button_to "Login", login_path, {:class => "btn btn-success inline", :form_class => "form-inline form-horizontal"} %>
or <%= button_to 'Register', register_path, {:class => "btn btn-primary inline", :form_class => "form-inline form-horizontal"} %>
<% end %>
</div>
Same goes for the logout button that renders when the user is logged in. I have tried putting various things in button_to
class as well as its form_class
, nothing worked so far, each button is on its own line. Any help or hints greatly appreciated!
You can access the style properties of the form created by the button_to helper using this syntax:
<%= button_to "Login", login_path, form: {style: 'display:inline-block;'}%>
Rails generates a form with a div inside for button_to
. To make it inline, you need to change both the form and the div to inline. In your css, add
.button_to,
.button_to div {
display: inline;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With