Skip to content

Chaning link_icon based on that instance parameter #1587

Closed
Logic-Seeker opened this Issue Apr 2, 2013 · 1 comment

3 participants

@Logic-Seeker

I would like to be able to change the link icon in the list view based on one of the attribute of that record.

register_instance_option :member do
15 true
16 end
17 register_instance_option :link_icon do
18 'icon-lock'
19 end
20 register_instance_option :controller do
21 Proc.new do
22 # Get all selected rows
23 @objects = list_entries(@model_config, :destroy)
24
25 # Update field published to true
26 @objects.each do |object|
27 @object.confirm!
28 end
29 redirect_to back_or_index
30 end
31 end

I would like to update my link_icon to 'icon-ok' when the action is performed

@billguy
billguy commented May 20, 2014

Better late than never but you could do something like:

register_instance_option :link_icon do
  Comment.where(commentable_type: bindings[:abstract_model].model_name, commentable_id: bindings[:object].id).count > 0 ? 'icon-user orange' : 'icon-user'
end

although it can get expensive.

@mshibuya mshibuya closed this Mar 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.