Reputation: 6981
I want to be able to update a record via params. Something like this:
http://domain.com/api/v1/notes/2190/notify?message=test
But it just returns a page not found. Pretty standard routes going on:
resources :notes, only: [:show] do
post 'notify'
end
My notify
method looks like this:
def notify
@note = Note.find(params[:id])
if params[:message]
render text: @note.update_attributes(message: params[:message])
end
end
Do I need to do anything else to permit this functionality? Any advice at all? I can't figure it out. Cheers.
Upvotes: 0
Views: 42
Reputation: 31467
The routes should be something like:
resources :notes, only: :show do
member do
get 'notify'
end
end
Upvotes: 1