http DELETE and roar

14 views
Skip to first unread message

Jose Alberto Suárez López

unread,
Dec 10, 2013, 12:00:21 PM12/10/13
to roar...@googlegroups.com
Hello,

I'm just testing ROAR (& roar-rails) for an rails4 based API and I'm having a small problem trying to implement the DELETE verb.

I'm trying something like this:

DELETE /users/ID/items/ID

def destroy
    user = User.find(params[:user_id])
    user.items.find(params[:id])
    respond_with user
end

But I got this error:

NoMethodError (undefined method `head' for #<API::ItemsController:0x00000006c3b9e0>):
  app/controllers/api/litems_controller.rb:23:in `destroy'

Is this the best way to implement a DELETE command?

I'm tempted to do something like:

render json: { status: 'ok' }

TIA

Andrés Freyría

unread,
Dec 10, 2013, 12:52:38 PM12/10/13
to roar...@googlegroups.com
I haven't used rails 4, but this doesn't look related to roar. Which one is line 23? Also, the code that actually deletes the item is missing.

FWIW, on successful delete actions I return 204 (`render nothing: true, status: 204`)


Andrés Freyría Cedeño


2013/12/10 Jose Alberto Suárez López <jalbe...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Roar" group.
To unsubscribe from this group and stop receiving emails from it, send an email to roar-talk+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

José Alberto Suárez López

unread,
Dec 10, 2013, 1:12:23 PM12/10/13
to roar...@googlegroups.com
'respond_with user' is the line 23

So you are right, return a 204 looks more correct


--
You received this message because you are subscribed to a topic in the Google Groups "Roar" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/roar-talk/HR61pJT-RqE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to roar-talk+...@googlegroups.com.

Andrés Freyría

unread,
Dec 10, 2013, 1:18:09 PM12/10/13
to roar...@googlegroups.com
Are you using roar-rails as well, or just roar? Also, could you post the entire stack trace in a gist? That's as far as I can help, but Nick should be able to look into it further.


Andrés Freyría Cedeño


2013/12/10 José Alberto Suárez López <j...@josealberto.org>

Nick Sutterer

unread,
Dec 10, 2013, 6:11:58 PM12/10/13
to roar...@googlegroups.com
Hi guys! That's definitely not Roar, looks more as if Rails does fun stuff. You should do what Andrés says (as always)!

:)
Reply all
Reply to author
Forward
0 new messages