SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot HenriIV's Avatar
    Join Date
    Jun 2004
    Location
    France
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Rails] route problem

    Hi,

    I'm stuck again with a route. Instead of using :controller/:action/:id like this
    /hotel/show/2, I'd like to use a kind of pretty url like
    /hotel/show/city-ref-id.rhtml or better html where city, ref and id are fields in the hotels table.

    Is it possible to do it in a simple way?

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    :controller/:action/:city-:ref-:id.html

    Wouldn't that work, as long as you match up city and ref in your queries and set proper regex patterns (i.e. no dashes in :city or :ref)?

  3. #3
    SitePoint Zealot HenriIV's Avatar
    Join Date
    Jun 2004
    Location
    France
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem is that I need to retrieve city name from cities table because :city will only returns an id (FK)

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Use a custom find() query with :include or :joins, that should get the city name.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •