I'm a bit confused with using an advanced ransack search. I'm trying do make a custom search where not all table names can be selected as search terms and not all predicates are used. I used railscast as a tutorial for this but I can't find anything how to limit the number of predicates. Is there also a possibility to use the names of preicates and table fields in different language (just labels)?
My search form
= search_form_for @q, :url => search_offers_path, :html => { :method => :post } do |f|
= f.condition_fields do |c|
.field
= f.attribute_fields do |a|
= a.attribute_select
= f.predicate_select
= f.value_fields do |v|
= v.text_field :value
= link_to "#{t :destroy}", '#', class: "remove_fields"
= link_to_add_fields "#{t :add}", f, :condition
.field
= t :sort
= f.sort_fields do |s|
= s.sort_select
= f.submit "#{t :search}"
My controller
def index
select_offers = Offer.where { (user_id != id) & (ended == false) & ((created_at + life_time ) > DateTime.now) }
@q = select_offers.search(params[:q])
@offers = @q.result(:distinct => true).page(params[:page])
@q.build_condition
@q.build_sort if @q.sorts.empty?
end