logo
down
shadow

Active admin customize filter only specific attribute


Active admin customize filter only specific attribute

By : Pixel Me Pink
Date : November 29 2020, 09:01 AM
With these it helps I have active admin integrated to my app. In Users section the filter is having too many attributes and if I have to customize one the condition in the filter I have to re-write the entire filter again. Can someone suggest me a way to modify a specific condition of the filter than rewriting the entire filter. I want to modify condition for Names list from the attachment.
code :
preserve_default_filters! # build the default filters
remove_filter :website_users # remove a default filter
filter :names, collection: proc { Name.all.map{ |c| [c.text, c.id] } }


Share : facebook icon twitter icon
Changing what attribute is displayed in drop down association filter in active admin with Rails 3.1 app

Changing what attribute is displayed in drop down association filter in active admin with Rails 3.1 app


By : Masoud
Date : March 29 2020, 07:55 AM
With these it helps I was able to solve my problem by passing :label_method => :company_name to the resource in the resources.rb file under the 'admin' directory.
Active Admin custom filter. Filter date by day | month | year of a Date attribute

Active Admin custom filter. Filter date by day | month | year of a Date attribute


By : Jennifer Hallquist
Date : March 29 2020, 07:55 AM
To fix this issue Here is a solution:
On my Active Admin resource (app/admin/employees.rb) I put:
code :
filter :month, :as => :select, :collection => (1..12)
scope :month_eq, lambda{ |month| where("strftime('%m', birthday) + 0 = ?", month.to_i) }

search_methods :month_eq
Active Admin: How to customize labels for select filter?

Active Admin: How to customize labels for select filter?


By : R Das
Date : March 29 2020, 07:55 AM
hop of those help? This seems like it should be fairly simple, buy I haven't been able to find any documentation on the subject. , The quick and easy:
code :
filter :archived, as: :select, collection: [['Live', 'true'], ['Archived', 'false']]
# Somewhere, in an initializer or just straight in your activeadmin file:
class ActiveAdmin::Inputs::FilterIsArchivedInput < ActiveAdmin::Inputs::FilterSelectInput
  def input_options
    super.merge include_blank: 'All'
  end

  def collection
    [ ['Live', 'true'], ['Archived', 'false'] ]
  end
end

# In activeadmin
filter :archived, as: :is_archived
Calculate quantity based on one Category attribute in Active Admin Dashboard (Rails 3.2/ active-admin 1.0)

Calculate quantity based on one Category attribute in Active Admin Dashboard (Rails 3.2/ active-admin 1.0)


By : FunkyFrog
Date : March 29 2020, 07:55 AM
To fix this issue I am building a daily deal app to learn on Ruby on Rails. , There are two ways to do this. In pure ruby:
code :
# (this is a bad idea)
data = Agency.joins('left outer join deals on deals.agency_id = agencies.id').
  select('agencies.agency_type, count(deals.id) as deals_count').group 'agency_type'

panel "Top Agency Types" do
  table_for data do
    column :agency_type
    column '# of Deals', :deals_count
  end
end
Count occurrence of values in a serialized attribute(array) in Active Admin dashboard (Rails, Active admin 1.0, Postgres

Count occurrence of values in a serialized attribute(array) in Active Admin dashboard (Rails, Active admin 1.0, Postgres


By : Darly Burbano
Date : March 29 2020, 07:55 AM
hop of those help? I can't think of any clean way to get the results you're after through ActiveRecord but it is pretty easy in SQL.
All you're really trying to do is open up the deal_goal arrays and build a histogram based on the opened arrays. You can express that directly in SQL this way:
code :
with expanded_deals(id, goal) as (
    select id, unnest(deal_goal)
    from deals
)
select goal, count(*) n
from expanded_deals
group by goal
with
    all_goals(goal) as (
        values ('traffic'),
               ('acquisition'),
               ('branding'),
               ('qualification')
    ),
    expanded_deals(id, goal) as (
        select id, unnest(deal_goal)
        from deals
    )
select all_goals.goal goal,
       count(expanded_deals.id) n
from all_goals
left join expanded_deals using (goal)
group by all_goals.goal
Deal.connection.select_rows(%q{ SQL goes here }).each do |row|
  goal = row.first
  n    = row.last.to_i
  #....
end
with some_cte(colname1, colname2, ...) as ( some_pile_of_complexity )
select * from some_cte
select * from ( some_pile_of_complexity ) as some_cte(colname1, colname2, ...)
select * from (values (1), (2)) as dt
shadow
Privacy Policy - Terms - Contact Us © animezone.co