Configure the routes in rails

81 views
Skip to first unread message

Pradeep Achuthan

unread,
Apr 16, 2014, 5:05:29 AM4/16/14
to rubyonra...@googlegroups.com


Hi,

I am creating a web service in rails application and I need to configure routes with respect to "books/book_id/delete" with post method.

But since I will not have a view page for this to create a book item, for testing purpose I am typing the url in the browser as

    localhost:3000/books/book_id/delete

But now when I type the above url in browser it is taking as GET request and showing error msg as

Routing Error

No route matches [GET] "/books/sherlock/delete"

Try running rake routes for more information on available routes.


So how do I configure the routes for the above.

*** Mateus ***

unread,
Apr 16, 2014, 5:15:49 AM4/16/14
to rubyonra...@googlegroups.com
HTTP POST request cannot be sent via URL.
You need to use some external tool such as cURL or wget.




--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5432c2b6-3343-47c4-b4ca-f4c017d77cba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

prabhu

unread,
Apr 16, 2014, 5:19:17 AM4/16/14
to rubyonra...@googlegroups.com
Sorry it was for delete method.. So for DELETE method is it possible

*** Mateus ***

unread,
Apr 16, 2014, 5:23:33 AM4/16/14
to rubyonra...@googlegroups.com
What's the output of $rake routes ?


*** Mateus ***

unread,
Apr 16, 2014, 5:32:19 AM4/16/14
to rubyonra...@googlegroups.com
By the way, It's also worth it to have a look on this rest-client 
You could just do 
RestClient.delete 'http://example.com/resource'

prabhu

unread,
Apr 16, 2014, 5:53:13 AM4/16/14
to rubyonra...@googlegroups.com


The rake routes shows the below

GET    /books/:book_id/new/*q_params(.:format) books#new
        /books/:book_id/next(.:format)          book#nextItem
 DELETE /books/:book_id/delete(.:format)        books#delete
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.

Colin Law

unread,
Apr 16, 2014, 6:02:17 AM4/16/14
to rubyonra...@googlegroups.com
On 16 April 2014 10:19, prabhu <pradeep....@gmail.com> wrote:
> Sorry it was for delete method.. So for DELETE method is it possible

Delete is done using a POST so again you cannot do this using just the
url in the browser, that will always ask for a GET.

Colin
> https://groups.google.com/d/msgid/rubyonrails-talk/5a1b3b18-616f-4f67-bb21-46514d3a9c86%40googlegroups.com.

prabhu

unread,
Apr 16, 2014, 6:03:54 AM4/16/14
to rubyonra...@googlegroups.com
Without RestClient it cannot be achievalbe.?

*** Mateus ***

unread,
Apr 16, 2014, 6:07:17 AM4/16/14
to rubyonra...@googlegroups.com
Yes it can. Build your own client which sends POST request or via either cURL or Wget
=D


prabhu

unread,
Apr 16, 2014, 6:10:02 AM4/16/14
to rubyonra...@googlegroups.com

prabhu

unread,
Apr 16, 2014, 6:10:18 AM4/16/14
to rubyonra...@googlegroups.com


On Wednesday, 16 April 2014 04:15:49 UTC-5, Mateus Couto wrote:
HTTP POST request cannot be sent via URL.
You need to use some external tool such as cURL or wget.


On Wed, Apr 16, 2014 at 7:05 PM, Pradeep Achuthan <pradeep....@gmail.com> wrote:


Hi,

I am creating a web service in rails application and I need to configure routes with respect to "books/book_id/delete" with post method.

But since I will not have a view page for this to create a book item, for testing purpose I am typing the url in the browser as

    localhost:3000/books/book_id/delete

But now when I type the above url in browser it is taking as GET request and showing error msg as

Routing Error

No route matches [GET] "/books/sherlock/delete"

Try running rake routes for more information on available routes.


So how do I configure the routes for the above.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.

Colin Law

unread,
Apr 16, 2014, 6:20:58 AM4/16/14
to rubyonra...@googlegroups.com
On 16 April 2014 11:03, prabhu <pradeep....@gmail.com> wrote:
> Without RestClient it cannot be achievalbe.?

The normal automated tests that any Rails app should include will test
it (using rspec for example). If you don't know how to do this then
work right through a good rails tutorial such as railstutorial.org
(which is free to use online), that will show you how to test the
interface. The tutorial mostly focusses on a normal application with
a UI but the testing methods are fundamentally the same for a web
service.

Colin
> https://groups.google.com/d/msgid/rubyonrails-talk/b860079a-72f8-4b0b-9c73-9abbe20b5ea3%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages