rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: Hez Ronningen <hronningen@gmail.com>
To: rack-devel@googlegroups.com
Subject: help with Mount::GeneratableRegexp#generate
Date: Thu, 16 Sep 2010 16:19:44 -0700	[thread overview]
Message-ID: <E202F0D7-0A5C-4E30-92E7-F6E342187F9F@gmail.com> (raw)

Hello,

rails ver: 3.0.0
rack (1.2.1)
rack-mount (0.6.13)
rack-cache (0.5.3)

I've been digging around in the internals of the router for a while trying to diagnose a strange behaviour. On most pages our links are generated with url_for and it works well, but on one page it generates a very confusing url. These urls are in the application layout so the code is pretty much the same.

example good url:
http://localhost:3000/quick-links/about-us

example bad url:
http://localhost:3000/pages/20?path[]=quick-links&path[]=about-us

I ended up digging all the way in to the GeneratableRegexp and found that the difference between the urls is in the malformed one a recall hash is passed in. I have found a line of code where I think the problem originates from...
Line ~55
merged = recall.merge(params)

What happens here is the recall hash is merged with the destination urls hash. What happens next is key, the GeneratableRegexp tries to see if all the requirements have been meet for this route. But we have contaminated the data with params from the recall url, so variables that weren't in the original destination url are used in the check and in the generation process.

I'm not sure the solution here, any ideas?

Cheers,
Hez

                 reply	other threads:[~2010-09-17  1:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://groups.google.com/group/rack-devel

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E202F0D7-0A5C-4E30-92E7-F6E342187F9F@gmail.com \
    --to=rack-devel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).