Created
July 22, 2009 15:47
-
-
Save phinze/152057 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vendor/plugins/has_associated_data | |
def ModelFoo < ActiveRecord::Base | |
has_associated_data do |a| | |
a.building :through => [:animal_location] | |
a.method_i_want_exposed :through => [:association, :chain, :to, :get, :there], :attr => :if_different_than_exposed_method | |
end | |
def building | |
end | |
def building= | |
end | |
named_scope :sorted_by_building_{asc/desc} | |
named_scope :sorted_by_{column}_{asc/desc} | |
end | |
## what does it look like in the controller | |
class FooController < ActionController::Base | |
def index | |
@collection_i_want_listed = FooModel.sorted_by_params(params) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment