- Most Recent |
24 hours |
7 days |
30 days |
365 days |
extjswithrails.com —
This Ruby on Rails plugin from Steffen Hiller provides an easy way to order ActiveRecord attributes for using them for csv exports or automated table generation.
Posted by
aroedl 8 months ago
aroedl 8 months ago Installation
git clone git://github.com/steffen/ordered_attributes.git vendor/plugins/ordered_attributes
On Edge Rails:
script/plugin install git://github.com/steffen/ordered_attributes.git
Example
class Person < ActiveRecord::Base
attr_order :name, :street, :zip, :city
attr_groups :address => [:street, :zip, :city],
:birth => [:date_of_birth, :place_of_birth], // you can use %w(date_of_birth place_of_birth) as well
:all => [:name, :address, :birth]
end
Use the ordered_attributes method to get the ordered attributes:
Person.ordered_attributes
=> [:name, :street, :zip, :city]
Person.ordered_attributes(:all)
=> [:name, :street, :zip, :city, :date_of_birth, :place_of_birth]
Please visit the linked website for more information.
Please log in or sign up and vote for this trick if it was helpful for you.
Don't forget to subscribe to our
RSS/Atom feed to get the latest tricks.
Don't forget to subscribe to our
RSS/Atom feed to get the latest tricks.









