Module: InheritedViews::TableBuilder::ClassMethods
- Defined in:
- lib/inherited_views/table_builder.rb
Instance Method Summary collapse
- #default_table_columns ⇒ Object
-
#table(*columns) ⇒ Object
Sets the columns to be displayed when the index table is rendered for this resource.
Instance Method Details
#default_table_columns ⇒ Object
21 22 23 |
# File 'lib/inherited_views/table_builder.rb', line 21 def default_table_columns resource_class.content_columns.collect{|column| column.name.to_sym } end |
#table(*columns) ⇒ Object
Sets the columns to be displayed when the index table is rendered for this resource.
Simple usage:
Pass in a list of the methods to call on your resource in the order you wish to see them in the table
class UsersController < InheritedViews::Base
table :first_name, :last_name
end
Except:
You can also use the default content columns from your ActiveRecord object and only exclude certain columns.
class UsersController < InheritedViews::Base
table :except => :first_name
end
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/inherited_views/table_builder.rb', line 48 def table(*columns) = columns. if [:except] [:except] = [:except].is_a?(Array) ? [:except] : [[:except]] columns = default_table_columns [:except].each{|c| columns.delete(c) } end self.table_config = .merge(:columns => columns) end |