Method: ActiveResource::Base.build

Defined in:
lib/active_resource/base.rb

.build(attributes = {}) ⇒ Object

Builds a new, unsaved record using the default values from the remote server so that it can be used with RESTful forms.

Options

  • attributes - A hash that overrides the default values from the server.

Returns the new resource instance.



924
925
926
927
# File 'lib/active_resource/base.rb', line 924

def build(attributes = {})
  attrs = self.format.decode(connection.get("#{new_element_path(attributes)}", headers).body).merge(attributes)
  self.new(attrs)
end