module RecordSelect::Actions
Public Instance Methods
Source
# File lib/record_select/actions.rb, line 5 def browse query = record_select_query @count = query.count if record_select_config.pagination? @count = @count.length if @count.is_a? Hash pager = ::Paginator.new(@count, record_select_config.per_page) do |offset, per_page| search = record_select_select ? query.select(record_select_select) : query search = search.limit(per_page).offset(offset) if record_select_config.pagination? search.includes(record_select_config.include).order(record_select_config.order_by).to_a end @page = pager.page(params[:page] || 1) respond_to do |wants| wants.html { render_record_select :partial => 'browse'} wants.js { if params[:update] render_record_select :template => 'browse' else render_record_select :partial => 'browse' end } wants.yaml {} wants.xml {} wants.json {} end end
:method => :get params => [:page, :search]
Source
# File lib/record_select/actions.rb, line 33 def select klass = record_select_model record = klass.find(params[:id]) if record_select_config.notify.is_a? Proc record_select_config.notify.call(record) elsif record_select_config.notify send(record_select_config.notify, record) end render :nothing => true end
:method => :post params => [:id]
Private Instance Methods
Source
# File lib/record_select/actions.rb, line 65 def record_select_query query = record_select_model user_includes = record_select_includes query = query.includes(user_includes).references(user_includes) if user_includes.present? query = query.joins(record_select_config.joins).distinct if record_select_config.joins.present? query = query.left_joins(record_select_config.left_joins) if record_select_config.left_joins.present? record_select_conditions.inject(query) { |query, cond| query.where(cond) } end
Source
# File lib/record_select/actions.rb, line 74 def record_select_views_path "record_select" end