Skip to content

Instantly share code, notes, and snippets.

@s-andringa
Created August 27, 2009 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s-andringa/176335 to your computer and use it in GitHub Desktop.
Save s-andringa/176335 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
def email
# Make REST call, parse response, extract email address and return it.
# Probably not the most concise and expressive code.
end
end
# Is more or less equal to:
class RemoteUser < ActiveResource::Base
self.site = "..."
end
class User < ActiveRecord::Base
def email
RemoteUser.find(remote_user_id).email
end
end
# Is equal to:
class User < ActiveRecord::Base
has_remote :site => "..."
def email
User::Remote.find(remote_user_id).email
end
end
# Is equal to:
class User < ActiveRecord::Base
has_remote :site => "..."
def email
remote.email
end
end
# Is equal to:
class User < ActiveRecord::Base
has_remote :site => "..." do |r|
r.attribute :email
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment