REST resource routes

21 views
Skip to first unread message

Ashley Moran

unread,
Nov 6, 2009, 7:04:05 AM11/6/09
to ram...@googlegroups.com
Hi

I tried to write a simple single-resource app the other day to help
with some debugging. I noticed the old REST helper has gone, to be
replaced with contrib/rest

But the new contrib/rest is incomplete. It routes all GET requests to
show, where it needs to route "/resource" and "/resource/1"
differently. Because of it rewriting the URL, this is actually quite
hard. It generates "/resource/1/show" instead of "/resource/show/1",
which means it tries to call "Controller#1('show')" instead of
"Controller#show('1')".

Because I couldn't see a way round the problems I eventually gave up
and used Merb instead. There it's possible to do this:

Merb::Router.prepare do
resources :my_resource
end

(The Merb router is one of the best things about Merb.)

Is there an easy way to do REST routes in Ramaze?

And, as an idle thought, would it possible to use the Merb router in
Ramaze? I haven't dug into the internals to investigate it, in case
someone can give an easy yes/no/maybe.

Cheers
Ashley


--
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran

James Britt

unread,
Nov 6, 2009, 2:13:15 PM11/6/09
to ram...@googlegroups.com
Ashley Moran wrote:

>
> Is there an easy way to do REST routes in Ramaze?

I had frustration with the REST code in Ramaze, and decided that the
application should not be concerned with how things get to it.

So I wrote some Rack middleware to handle that.

http://github.com/Neurogami/restafarian

It may offer some useful stuff.


>
> And, as an idle thought, would it possible to use the Merb router in
> Ramaze? I haven't dug into the internals to investigate it, in case
> someone can give an easy yes/no/maybe.

Good question.


--
James Britt

www.jamesbritt.com - Playing with Better Toys
www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff
www.neurogami.com - Smart application development

Ashley Moran

unread,
Nov 6, 2009, 3:34:25 PM11/6/09
to ram...@googlegroups.com

On 6 Nov 2009, at 19:13, James Britt wrote:

> I had frustration with the REST code in Ramaze, and decided that the
> application should not be concerned with how things get to it.

I fully agree. I'm not personally too keen on Controller.map
(presumably actually included in either Innate::Node or some other
module - I'm not yet familiar with any of the internals...), although
it's an easy way to get things going.

> So I wrote some Rack middleware to handle that.
>
> http://github.com/Neurogami/restafarian
>
> It may offer some useful stuff.

Thanks for the link. I've never written Rack middleware, so it's
still a bit foreign to me. It's a shame there are no specs for it, as
that would make it easier to see what the transform is doing.

> Good question.

I think I may just roll my sleeves up and have a go. At worst, it
won't work, but I'll have learnt a lot more about Ramaze and Merb (and
possibly Rack).

Clive Crous

unread,
Nov 6, 2009, 4:21:20 PM11/6/09
to ram...@googlegroups.com
> On 6 Nov 2009, at 19:13, James Britt wrote:
>
>> I had frustration with the REST code in Ramaze, and decided that the
>> application should not be concerned with how things get to it.

I agree as well. For our company's RESTful API I have a 90 line
Ramaze::Rewrite dispatcher which I need to modify each time I add a
new resource.
This was the only way to shoehorn REST into Ramaze :(

Clive

Ashley Moran

unread,
Nov 6, 2009, 5:27:01 PM11/6/09
to ram...@googlegroups.com

On 6 Nov 2009, at 21:21, Clive Crous wrote:

> I agree as well. For our company's RESTful API I have a 90 line
> Ramaze::Rewrite dispatcher which I need to modify each time I add a
> new resource.
> This was the only way to shoehorn REST into Ramaze :(

Hmmm, hmmm, hmmm...

How much would everyone here like to be able to use the Merb (RESTful)
router in Ramaze? If there's any demand, I might make a serious stab
at it. When it's not Friday night...

I'm still happy with Merb, but I'm a bit concerned with the lack of
progress due to "Rails 3". I like a lot of things in Ramaze, just not
the routing. But I'd like more input from more experienced Ramaze
users/developers as to what the roadmap is.

Ben

unread,
Nov 10, 2009, 10:02:53 PM11/10/09
to Ramaze
I'd love to see some additional routing flexibility for Ramaze. One
thing I really like about using Sinatra for example is the easy
control over urls it gives you. Having a url generation helper with
that would be nice as well (makes rewiring things much easier).

Anyway, I came across a rack router project in my research on the
subject, haven't really looked into it, but it might be relevant:

Announcement:

http://groups.google.com/group/rack-devel/browse_thread/thread/41334bce83cb173f

Source:

http://github.com/carllerche/rack-router

So definitely +1.

Ben

Ashley Moran

unread,
Nov 16, 2009, 7:31:19 AM11/16/09
to ram...@googlegroups.com

On Nov 11, 2009, at 3:02 am, Ben wrote:

> Source:
>
> http://github.com/carllerche/rack-router
>
> So definitely +1.

Looks like there's interest in this idea then. The rack-router project looks like it has stalled though. I'm gonna have to see if I can squeeze in any time to work on this. Right now, routing is putting me off using Ramaze more.

Reply all
Reply to author
Forward
0 new messages