Module: RecordSelect::Actions

Defined in:
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
# File '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, (params[:per_page] || record_select_config.per_page).to_i) 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)

  render_record_select((params[:update] ? 'browse.rjs' : '_browse.rhtml')) and return if params[:format] == "js"
  render_record_select '_browse.rhtml', :layout => true
end

#selectObject

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



26
27
28
29
30
31
32
33
34
35
# File 'lib/record_select/actions.rb', line 26

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