Module: RecordSelect::Actions

Defined in:
lib/six-updater-web/vendor/plugins/recordselect/lib/record_select/actions.rb

Instance Method Summary collapse

Instance Method Details

#browseObject

:method => :get params => [:page, :search]



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/six-updater-web/vendor/plugins/recordselect/lib/record_select/actions.rb', line 5

def browse
  conditions = record_select_conditions
  klass = record_select_config.model
  @count = klass.count(:conditions => conditions, :include => record_select_includes)
  pager = ::Paginator.new(@count, record_select_config.per_page) do |offset, per_page|
    klass.find(:all, :offset => offset,
                     :include => [record_select_includes, record_select_config.include].flatten.compact,
                     :limit => per_page,
                     :conditions => conditions,
                     :order => record_select_config.order_by)
  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', :format => :js, :layout => false
      else
        render_record_select :partial => 'browse'
      end
    }
    wants.yaml {}
    wants.xml {}
    wants.json {}
  end
end

#selectObject

:method => :post params => [:id]



35
36
37
38
39
40
41
42
43
44
# File 'lib/six-updater-web/vendor/plugins/recordselect/lib/record_select/actions.rb', line 35

def select
  klass = record_select_config.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