Default filter for active record

22 views
Skip to first unread message

Mocha Tony

unread,
Jun 12, 2013, 4:24:36 AM6/12/13
to actives...@googlegroups.com
Hello

I am trying to implement default filter for my page. 

For my case, I have tables "feeds" that storing news feed from different country, what I want is by default the page will filter by "US", but also allowed the user to filter by other country records when they start searching. I implement search function with field_search. 

How do I implement this with ActiveScaffold. Below is my working code:

class FeedsController < ApplicationController
  
  active_scaffold :feed do |config|

    config.list.per_page = 30    
    config.actions.add :field_search
    config.field_search.columns = [:site, :state,:created_at,:title]
    config.columns[:site].search_ui = :select
    config.columns[:state].search_ui = :select

    config.list.sorting = {:created_at => 'DESC'}
    config.list.columns = [:created_at, :end_at, :state, :site, :image_url, :title]
  end

end

Thank you

Sergio Cambra

unread,
Jun 12, 2013, 6:12:47 PM6/12/13
to actives...@googlegroups.com

Try with this

 

def field_search_params

  current_search = super

  current_search[:state] ='US' if current_search.empty?

  current_search

end

--
You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email to activescaffol...@googlegroups.com.
To post to this group, send email to actives...@googlegroups.com.
Visit this group at http://groups.google.com/group/activescaffold?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

 

 

Tim Uckun

unread,
Jun 12, 2013, 7:28:37 PM6/12/13
to actives...@googlegroups.com
Has anybody looked into integrating ransack with AS?
Reply all
Reply to author
Forward
0 new messages