module RecordSelect::Actions
Public Instance Methods
browse()
click to toggle source
:method => :get params => [:page, :search]
# File lib/record_select/actions.rb, line 5 def browse conditions = record_select_conditions klass = record_select_model @count = append_to_query(klass, {:where => conditions, :includes => record_select_includes}).count @count = @count.length if @count.is_a? ActiveSupport::OrderedHash pager = ::Paginator.new(@count, record_select_config.per_page) do |offset, per_page| append_to_query(klass, {:offset => offset, :select => record_select_select||"*", :includes => [record_select_includes, record_select_config.include].flatten.compact, :limit => per_page, :where => conditions, :reorder => 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.js', :layout => false else render_record_select :partial => 'browse' end } wants.yaml {} wants.xml {} wants.json {} end end
select()
click to toggle source
:method => :post params => [:id]
# File lib/record_select/actions.rb, line 37 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
Protected Instance Methods
append_to_query(query, options)
click to toggle source
# File lib/record_select/actions.rb, line 63 def append_to_query(query, options) options.assert_valid_keys :where, :select, :group, :reorder, :limit, :offset, :joins, :includes, :lock, :readonly, :from options.reject{|k, v| v.blank?}.inject(query) do |query, (k, v)| query.send((k.to_sym), v) end end
record_select_model()
click to toggle source
# File lib/record_select/actions.rb, line 77 def record_select_model record_select_config.model end
record_select_views_path()
click to toggle source
# File lib/record_select/actions.rb, line 72 def record_select_views_path "record_select" end