Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

path helper problem

#6126

Hi,
i'm expecting some problem with path helpers. Let me explain. I have some resource "issues" in my routes and would like to use helper with parameter issue_path("something"). Everything works fine if parameter does not contain dot(.) symbol, but for issue_path("some.thing") it will cause error like

ActionController::RoutingError in Issues#index

Showing /Users/alec/Documents/Projects/prj/app/views/issues/_issue.html.haml where line #30 raised:

No route matches {:controller=>"issues", :id=>"some.thing", :action=>"show"}

Reported by Alexey Poimtsev · December 7th, 2010 @ 09:01 PM

State: invalid
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. 2kan
    2kan

    I don't think that it is a bug. I think there is a reason why you can't use dots.

    If you are interested here is a regexp for such route:

    /\A\/issues\/([^\/.?]+)(?:\.([^\/.?]+))?\Z/
    

    Here are segments (for better understanding) for this route:

    segments: ["/issues/", /(?<id>\A[^/.?]+\Z)/, [".", /(?<format>\A[^/.?]+\Z)/]]
    

    I think you can't use dots because of format segment but i'm not sure, any ideas why dot is not allowed?

    December 8th, 2010 @ 02:30 PM

  2. 2kan
    2kan

    Yes, of course '.' is not allowed because it is separator for format.

    December 8th, 2010 @ 02:34 PM

  3. Alexey Poimtsev
    Alexey Poimtsev

    ok, but sometimes we need to send '.' in path, what about encode/escape dot symbol?

    December 8th, 2010 @ 02:38 PM

  4. Neeraj Singh
    Neeraj Singh
    • Importance changed from to Low

    In routes mention :format => false and then use your regex and then dot will be allowed.

    December 8th, 2010 @ 06:03 PM

  5. Todor Dragnev
  6. Alexey Poimtsev
  7. Andrew White
    Andrew White
    • State changed from new to invalid

    And #5994 where I've listed some more tickets that have reported the same problem.

    February 9th, 2011 @ 06:50 AM