Module: SimpleGrid::Helpers
- Defined in:
- lib/simple_grid/simple_grid_helpers.rb
Instance Method Summary collapse
- #remove_columns(columns, exclude) ⇒ Object
- #simple_grid(collection, options = {}) ⇒ Object
- #verify_params(options, key) ⇒ Object
Instance Method Details
#remove_columns(columns, exclude) ⇒ Object
17 18 19 20 21 |
# File 'lib/simple_grid/simple_grid_helpers.rb', line 17 def remove_columns(columns, exclude) display = [] exclude.nil? ? display = columns : columns.each { |c| display << c unless exclude.include?(c) } display end |
#simple_grid(collection, options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/simple_grid/simple_grid_helpers.rb', line 3 def simple_grid(collection, = {}) if collection.size > 0 current_model = collection.first.class columns = remove_columns(Rails.const_get(current_model.to_s).column_names.to_a, [:exclude_columns]) render :partial => '/simple_grid/grid', :locals => { :current_model => current_model.to_s.downcase, :columns => columns, :collection => collection, :extra_columns => verify_params(, :extra_columns), :actions => verify_params(, :actions) } else render :text => "No records to show." end end |
#verify_params(options, key) ⇒ Object
23 24 25 |
# File 'lib/simple_grid/simple_grid_helpers.rb', line 23 def verify_params(, key) .has_key?(key) ? [key] : {} end |