Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Putting button_to inline with text: twitter-bootstrap-rails

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!

like image 971
IKA Avatar asked Apr 26 '13 16:04

IKA


2 Answers

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;'}%>
like image 151
TWONEKSONE Avatar answered Nov 15 '22 09:11

TWONEKSONE


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;
}
like image 34
Eva Avatar answered Nov 15 '22 11:11

Eva