3
%p
  %br
  %span.footer_links
    = link_to 'Edit', edit_link_path(@link)
    = link_to 'Edit', edit_link_path(@link)
    = button_to 'Delete', @link, :confirm => 'Are you sure?', :method => :delete
    = button_to 'Delete', @link, :confirm => 'Are you sure?', :method => :delete
    pppppp

Produces "edit" links on the same line but delete buttons on different lines, e.g.

      edit  edit
      delete
      delete

(two of each for emphasis about line breaks)

How can I get all the above on 1 line as in:

edit edit [delete] [delete]

I am doing this becuase I need to change my link_to, :method => :delete to :button_to's

Update: I added, :class => '.btn' to my button_to with .btn { display: inline; } in my css but it hasn't helped.

<p>
<br/>
<span class="footer_links">
<a href="/links/354/edit">Edit</a>
 | 
</span>
</p>
<form method="post" action="/links/354" class="button_to">
<div>
<input name="_method" type="hidden" value="delete"/>
<input class=".btn" data-confirm="Are you sure?" type="submit" value="Delete"/>
<input name="authenticity_token" type="hidden" value="MvN6K03y5WcqSZRt4Au3zj+xsKhfZ9EEtkf2M7YCGhk="/>
</div>
</form>
<p/>
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497

1 Answers1

2

Strange, because both the a generated by link_to and the input generated by button_to should be inline elements.

This is exactly what CSS is for, though: keeping design details out of the HTML. So you could have CSS like this:

.footer_links a, .footer_links input {
  display: inline;
  padding-right: 1em;
}

[Useful edit - also from Buck - You can use :form_class and then style the form and the div inside it as inline. ]

Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
Buck Doyle
  • 6,333
  • 1
  • 22
  • 35
  • 1
    Oops, `button_to` actually [wraps the `input` in a `div`](http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-button_to). Well, add a `:class => '.inline-button'` or somesuch to the `button_to` and style that? Please show the generated HTML if you need further advice. – Buck Doyle Jun 01 '12 at 00:43
  • but I can't stop it appearing :( – Michael Durrant Jun 01 '12 at 01:21
  • You can use `:form_class` and then style the form and the div inside it as inline. – Buck Doyle Jun 01 '12 at 14:21
  • Here's an answer for this question that did the trick for me: https://stackoverflow.com/questions/16240754/putting-button-to-inline-with-text-twitter-bootstrap-rails – Yoni Jun 22 '22 at 02:22