Boolean toggle using rails_admin on list view

713 views
Skip to first unread message

Lee Graham

unread,
May 13, 2013, 2:42:31 PM5/13/13
to rails...@googlegroups.com

I have a basic rails_admin application and would like to be able to toggle a boolean value in the list viewof rails_admin.

For example, I have a scale model with an attribute 'activated'. When I log in to the rails_admin dashboard I see the scale model and the lists of various scales and the activated attribute with the boolean value.

How would I make this value editable in list view so I can change the boolean value from this view so I don't have to go in to the edit view to edit the value?

Thanks!

Benoit Bénézech

unread,
May 16, 2013, 4:21:11 AM5/16/13
to rails...@googlegroups.com
Show a checkbox in pretty_value with some id, and use custom/ui.js to add behavior: send AJAX requests to your own app.

gle...@gmail.com

unread,
Sep 13, 2013, 2:38:31 PM9/13/13
to rails...@googlegroups.com
I made a gem some time ago exactly for that purpose - rails_admin_toggleable

четверг, 16 мая 2013 г., 12:21:11 UTC+4 пользователь Benoit Bénézech написал:

ch...@ochsnet.com

unread,
Sep 14, 2013, 12:23:47 AM9/14/13
to rails...@googlegroups.com
With all the features rails admin has, I thought it was strange that you can't override fields on list views with partials.  I just added that feature to my own code today.  You can specify a partial for a field in list view and the value is there, it's just that the index view doesn't do anything with it.

I made it so that this:

field :myfield do
  partial true
end

results in the list view rendering the field in rails_admin/model_name/_myfeild.html.haml

This is the snippet I added to the index view to get this to work:
 %td{:class => "#{property.css_class} #{property.type_css_class}", :title => strip_tags(value.to_s)}
                - if property.partial === true
                  = render :partial => "/rails_admin/#{@abstract_model.param_key}/#{property.name}", :locals => { :object => object, :property => property, :value => value }
                - else
                  = value


Chris
Reply all
Reply to author
Forward
0 new messages