Forum: Ruby on Rails Configure restful web service in rails

881a236ca533281bb9c9ac92f380b5a0?d=identicon&s=25 prabhu (Guest)
on 2014-04-16 14:36
(Received via mailing list)
Hi,

I am trying to create a Rest web service in my rails application. I need
to
configure urls for it as below.


    localhost:3000/book/book_id/new/param1/param2/param3/param4/...

    localhost:3000/book/book_id/next

    localhost:3000/book/book_id/delete

I dont have a view pages for it since it returns in json format.Please
help.So what is the best way to configure these urls via routes.
881a236ca533281bb9c9ac92f380b5a0?d=identicon&s=25 prabhu (Guest)
on 2014-04-16 14:38
(Received via mailing list)

  
4c6bde00168d595053c09aac7e487f8e?d=identicon&s=25 Colin Law (Guest)
on 2014-04-16 14:49
(Received via mailing list)
On 16 April 2014 13:34, prabhu <pradeep.achuthan@gmail.com> wrote:
> Hi,
>
> I am trying to create a Rest web service in my rails application. I need to
> configure urls for it as below.
>
>
>     localhost:3000/book/book_id/new/param1/param2/param3/param4/...

That might be better as book/id/new?param1=..&param2=.. etc.
What is that url supposed to do?  If it makes a new book then why have
you got an id?

>
>     localhost:3000/book/book_id/next
>
>     localhost:3000/book/book_id/delete
>
> I dont have a view pages for it since it returns in json format.Please
> help.So what is the best way to configure these urls via routes.

Read the Rails Guide on Routing, that should explain how to do it.  If
there is something there you do not understand then come back and ask
about it.

Colin
280b78a61a968391b7e07e912be102a8?d=identicon&s=25 Robert Walker (robert4723)
on 2014-04-16 15:55
Colin Law wrote in post #1143272:
> On 16 April 2014 13:34, prabhu <pradeep.achuthan@gmail.com> wrote:
>> Hi,
>>
>> I am trying to create a Rest web service in my rails application. I need to
>> configure urls for it as below.
>>
>>
>>     localhost:3000/book/book_id/new/param1/param2/param3/param4/...
>
> That might be better as book/id/new?param1=..&param2=.. etc.
> What is that url supposed to do?  If it makes a new book then why have
> you got an id?

As Colin noted, if this is intended to create a new book then it seems
more logical to me to send this as a POST with the parameters in the
body of the request (either supplied as form data or JSON) and not in
the GET style of appending the parameters to the URI.
52f3528c40e9cf28ad0900886eecb128?d=identicon&s=25 Jordon Bedwell (Guest)
on 2014-04-16 16:08
(Received via mailing list)
On Wed, Apr 16, 2014 at 8:55 AM, Robert Walker <lists@ruby-forum.com>
wrote:
>> That might be better as book/id/new?param1=..&param2=.. etc.
>> What is that url supposed to do?  If it makes a new book then why have
>> you got an id?
>
> As Colin noted, if this is intended to create a new book then it seems
> more logical to me to send this as a POST with the parameters in the
> body of the request (either supplied as form data or JSON) and not in
> the GET style of appending the parameters to the URI.

One should not accept JSON input outside of a API interface built with
REST semantics because then you are just muddying the waters and
enforcing multiple types for something that is probably purely for
HTML and doesn't even need a secondary type.  It's a bad idea to
combine your API REST and REST interfaces for HTML into the same
endpoints.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.