I am using the best_in_place gem in a project, and i am trying to display a checkbox on it's own place, but i cannot do it. I am searching about it, but i cannot find out the answer anywhere. I just can find people talking about display either "no" or "yes"... Or anything else. But i just want to see the checkbox checked or not.
4 Answers
I am using font-awesome but you can use it also with bootstrap or other images. My solution for displaying checkboxes were simply using the raw
method to render a checkbox image (in my case one of the font-awesome icons)
= best_in_place @project,
:active,
:type => :checkbox,
:collection => {false: raw("<i class='icon-check-empty'></i>"), true: raw("<i class='icon-check'></i>")}
And now it looks like the following:

- 3,817
- 1
- 30
- 36
I've managed to make a hack-around using unicode characters ☐ and ☑
<span style='font-size: 1.75em;'>
<%= best_in_place a,
:bool,
:type => :checkbox,
:collection => ["☐", "☑"]%>
</span>
The <span>
wrapper helps with choosing the size in this case. This is a short term solution and a checkbox with an AJAX call would definitely be better I guess...

- 4,448
- 1
- 17
- 31
-
@megas, try encapsulating @Sash's collection with raw: `:collection => [raw("☐"), raw("☑")]` – Tass Jun 07 '13 at 17:32
I've forked the original best_in_place
gem and modified it with support for displaying an actual, standard HTML checkbox. My fork can be found here: https://github.com/jdashton/best_in_place
In case you're unfamiliar with using gems directly from github, the following line in your Gemfile should do the trick:
gem 'best_in_place', github: 'jdashton/best_in_place'

- 1,388
- 11
- 23
It's not supported in the current version. However, it's pretty easy to do. Create a checkbox where you need it, and fire an ajax call to the server with some javascript.
Check out this stackoverflow answer for an example.