Skip to content

Instantly share code, notes, and snippets.

@lperichon
Created October 7, 2011 17:27
Show Gist options
  • Save lperichon/1270858 to your computer and use it in GitHub Desktop.
Save lperichon/1270858 to your computer and use it in GitHub Desktop.
nested paremeters
def create
@contact = Contact.new(params[:contact])
if @contact.save
render :json => { :id => @contact.id }.to_json, :status => :created
else
render :json => { :message => "Sorry, contact not created",
:error_codes => [],
:errors => @contact.errors }.to_json, :status => 400
end
end
Started POST "/v0/contacts" for 127.0.0.1 at 2011-10-07 14:24:11 -0300
Processing by V0::ContactsController#create as */*
Parameters: {"contact"=>{"contact_attributes"=>["{\"type\"=>\"Telephone\", \"category\"=>\"home\", \"value\"=>\"12345\", \"public\"=>1}"], "first_name"=>"lala"}}
WARNING: Can't verify CSRF token authenticity
Completed 500 Internal Server Error in 15ms
NoMethodError (undefined method `metadata' for #<String:0xa577f4c>):
app/controllers/v0/contacts_controller.rb:52:in `new'
app/controllers/v0/contacts_controller.rb:52:in `create'
Rendered /home/luis/.rvm/gems/ruby-1.9.2-p290@crm-hub/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.3ms)
Rendered /home/luis/.rvm/gems/ruby-1.9.2-p290@crm-hub/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.7ms)
Rendered /home/luis/.rvm/gems/ruby-1.9.2-p290@crm-hub/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (3.5ms)
Typhoeus::Request.post( "http://localhost:3002/v0/contacts", :params => { "contact" => { "first_name" => "lala", "contact_attributes" => [{"type" => "Telephone", "category" => "home", "value" => "12345", "public" => 1}]}}, :timeout => 200 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment