RESTful Routes

I have purchased the peepcode tutorial on RESTful and I have to say it
is brilliant, one thing it does not answer is this question though.

I have been experimenting with rails on nothing serious and managed to
setup an application for which the routes did which for example did,

www.myapplication.com/company_name

therefore www.myapplication.com/google would pull up googles profile
from the database

I have looked at RESTful and that suggests
www.myapplication.com/companies/company_name
would be the RESTful way to do it, does that mean using RESTful style
routes I cannot achieve the configuration “www.myapplication.com/
company_name”?

Or am I just a rails n00b whos missed the point of RESTful?

Thanks for any help anyone can give me!

[email protected] wrote:

I have purchased the peepcode tutorial on RESTful and I have to say it
is brilliant, one thing it does not answer is this question though.

I have been experimenting with rails on nothing serious and managed to
setup an application for which the routes did which for example did,

www.myapplication.com/company_name

therefore www.myapplication.com/google would pull up googles profile
from the database

I have looked at RESTful and that suggests
www.myapplication.com/companies/company_name
would be the RESTful way to do it, does that mean using RESTful style
routes I cannot achieve the configuration “www.myapplication.com/
company_name”?

Or am I just a rails n00b whos missed the point of RESTful?

Thanks for any help anyone can give me!

REST means that all the state for specifying the resource is present in
the URL, instead of in the session or other server state. If
www.myapplication.com/company_name works for you, that’s fine. It’s a
perfectly valid RESTful URL. However, the map.resources helper will
probably have some kind of problem not having a controller name in the
url, but you can always roll the routes by hand (just specify the
:method in the :requirements). Just keep in mind this approach could
also lead to name collisions. Like, if you have a :cookies resource and
a “cookies” company, those names could collide. Other than that, it
shouldn’t be a problem.


Josh S.
http://blog.hasmanythrough.com

end
I would recommend against using the restful named routes in your
//jarkko


Jarkko L.
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi

Interesting Jarkko…

The restful routes, seem clearer than using urls, maybe not so much
for this case, but for very long urls, that include for example the
title of a blog, I would rather use blog_path(@blog).

Yes, I want to test the full stack, for sure! However, I don’t see how
using named routes, stops you from doing this…

Webrat two thumbs up, I’ve been using selenium up to now, but would
like to try other alternatives to see which one works better.

Regards,

Raimond G.

P.S. This message is repeated with the wrong subject somewhere in the
mailing list, sorry about that ;-|

NoMethodError: You have a nil object when you didn’t expect it!
Sorry, but I can’t really see anything related to rspec from the
backtrace. I changed to a named route in one of my own steps and it
worked fine. Can you try doing this in a rails integration test and
see if you have a different result?

Will do.

Thanks for the fast replies!

On 4.2.2008, at 19.16, Raimond G. wrote:

like to try other alternatives to see which one works better.
What I mean by testing the full stack is that you’d e.g. have this in
your story:

clicks_button “Delete”

If you just use “delete some_url”, there are two things that could be
missed:

  1. You have forgotten the DELETE method from your delete button.
  2. The actual url in the form doesn’t actually point to some_url.

Neither of the two would be caught unless you used something like
Webrat to drill through the whole stack. If you’re using blog_path in
the story, I feel like you’re using the route to test itself.

Cheers,
//jarkko


Jarkko L.
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi

using named routes, stops you from doing this…
missed:


Jarkko L.
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi

Excellent observations Jarkko!

I’m still trying to get my head around the concept of “testing the
full stack” and you just enlightened me a little more.

Thanks!

Rai

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs