ruby on rails - Pass current_scopes on to search -



ruby on rails - Pass current_scopes on to search -

i'm using helpful has_scope gem. have index page created passing scopes in link.

<%= user_collections_path(@user, got: true) %>

on index page can query current_scopes.

i have pretty standard ransack search form on page using returns results without scopes.

how can pass current_scopes on search? tried using hidden field couldn't work. thought if pass scopes in link ought able pass them in form after googling i'm not sure true.

search form

<%= search_form_for @search, :html => {:method => :post} |f| %> <%= f.text_field :name_or_miniature_name_cont, class: "span3" %> <%= f.submit "search", class: "btn" %> <% end %>

index method

def index @user = user.find_by_username(params[:user_id]) @search = apply_scopes(@user.collections).search(params[:q]) @search.sorts = 'created_at desc' if @search.sorts.empty? @collections = @search.result.paginate(page: params[:page]) end

you store / retrieve info current session rather set url parameter.

to quote comment on an issue:

this reason has_scope supports :default, can give proc retrieve value session:

has_scope :degree, :default => proc { |c| c.session[:some_value] }

ruby-on-rails ruby-on-rails-4 named-scope has-scope

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -