Skip to content

Instantly share code, notes, and snippets.

@sevos
Created October 6, 2011 11:29
Show Gist options
  • Save sevos/1267189 to your computer and use it in GitHub Desktop.
Save sevos/1267189 to your computer and use it in GitHub Desktop.
Class-Oriented example
class Department < ActiveRecord::Base
has_one :stock
end
class Stock < ActiveRecord::Base
belongs_to :department
def update
update_attribute :value, Legacy::Department.find(department.id).stock_value
end
end
class Legacy::Department < ActiveResource::Base
# stuff here
end
class StocksController
def update
Stock.where(:department_id => params[:department_id]).first.udpate
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment