Created
January 10, 2009 19:23
-
-
Save maccman/45534 to your computer and use it in GitHub Desktop.
This file contains 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
class UsersBinder < Binder::Collection | |
class << self | |
# self.items is a special method | |
# Basically it'll update users on the client side | |
def index | |
self.items = User.all | |
end | |
# def index(offset) | |
# self.items = User.all(:conditions => ['id > ?', offset]) | |
# end | |
def admins | |
self.items = User.admins.all | |
end | |
end | |
def update(attrs) | |
if @item.update_attributes(attrs) | |
flash[:notice] = "Successfully updated" | |
else | |
flash[:notice] = "Errors updating users" | |
end | |
end | |
def highlight | |
# Calls $('user_1').highlight() | |
self.element.highlight | |
end | |
# Overrides charge on user | |
def charge! | |
# calls charge! on model (i.e. do sql commit ) | |
self.item.charge! | |
# Now gui stuff | |
flash[:notice] = "Successfully charged" | |
highlight | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment