Hi, all! I'm new in Rails. I've read "Agile web development" and now I want made my very first rails application - photo album. But I don't know how to design it RESTful. For example I have 3 chapters and 100 photos on each one and i want list only 10 photos on page. How should look request for such resource? Maybe: site.my/chapter/2/4 (controller:chapter, action: chapter_id=2, page=4) If its good then how to send to controller 2 parameters ? Or maybe you can explain me how it can be done right way? And now I also want know in general how to process request like site.my/say/hello/to/homer I know if it just site.my/say/hello - then 'say' - it's controller and' hello' - it's action, but what when 'to' and 'homer'? How exactly tell my rails application whet I want say hello to Homer? Thanks in advance! PS sorry for so many stupid questions but I don't have any one next to me who about Rails((
on 2010-03-09 14:01
on 2010-03-09 18:22
DmitryPush wrote: > Hi, all! > I'm new in Rails. > I've read "Agile web development" and now I want made my very first > rails application - photo album. > But I don't know how to design it RESTful. > > For example I have 3 chapters and 100 photos on each one and i want > list only 10 photos on page. Forget about trying to engineer your URLs (save that for later if you want). Take a look at mislav-will_paginate for showing N items per page. Mix that with good use of the in_groups_of, and you can have a nice layout in rows and columns if that's your desire. > And now I also want know in general how to process request like > site.my/say/hello/to/homer > I know if it just site.my/say/hello - then 'say' - it's controller > and' hello' - it's action, but what when 'to' and 'homer'? > How exactly tell my rails application whet I want say hello to Homer? > You'll want to read up on specifying routes in rails to accomplish that task.
on 2010-03-09 22:59
DmitryPush wrote:
> site.my/chapter/2/4
It is my opinion that people often go overboard with the REST concepts.
As far as I'm concerned there's nothing non-RESTful about:
http://host/chapter/2/photos?page=4&per_page=10
The URL still identifies the resource, which would be the collection of
photos (nested under the chapter identified by 2). The query string is
just for controlling the paging. I don't see this as part of the
resource identifier URL, so the query string is a good place for it to
live.
on 2010-03-09 23:08
On Tue, Mar 9, 2010 at 3:59 PM, Robert Walker <lists@ruby-forum.com> wrote: > As far as I'm concerned there's nothing non-RESTful about: > > http://host/chapter/2/photos?page=4&per_page=10 I agree, but all the question marks and ampersands pretty much guarantee Google won't index it. -- Greg Donald destiney.com | gregdonald.com
on 2010-03-09 23:32
Greg Donald wrote: > On Tue, Mar 9, 2010 at 3:59 PM, Robert Walker <lists@ruby-forum.com> > wrote: >> As far as I'm concerned there's nothing non-RESTful about: >> >> http://host/chapter/2/photos?page=4&per_page=10 > > I agree, but all the question marks and ampersands pretty much > guarantee Google won't index it. I certainly get that point. However, that's a different issue, unrelated to the RESTfulness of a URI. There are cases where it's probably a good thing that Google doesn't index certain pages. There's way to much garbage that people force Google to index that just makes finding what you really want next to impossible. Forums that get indexed come to mind. It drives me nuts that such a large percentage of what I'm looking for gets obscured by a bunch of useless hits on forum discussions. Blogs, yes. Forum posts I could live without in my search results! SEO is great, and useful, for sites that provide really useful search content, but there much that needs to be put on the web that really has no business showing up in Google results.
on 2010-03-10 07:56
Hi,
you can try from other perspective, if you already have the
functionality to paginate the records in your model or controller and
the only need that you have are the parameters, you can try with a
simple map.connect like this =>
map.connect ":controller/:id_chapter/:page"
and ActionController will map =>
i rann it in the rails console =>
>> rs.recognize_path "chapter/2/4"
{:action => 'index', :page => "2", :id_chapter => "4",
:controller=>"chapter")
this variables are aviable in your @params.
but you'll be better if take the paginate-plugin approach, don´t put
that kind of logic in your route sistem.
Pdta: Sorry by mi English
Cristian Vasquez
MedellÃn-Colombia
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.