Your understanding is absolutely right.

My initial gut was indeed to try hidden inputs. But it does not work:

App B calls appA/foos/new?size=4&weight=2

App A foo/new method is called and the form is pre-populated with size
and weight.
The problem is, the URL is still appA/foos/new?size=4&weight=2. When
the form is submitted, I think what happens is Rails tries to append
the form parameters to the existing URL. Since that URL already
contains parameters it does something like:

appA/foos/new?size=4&weight=2?size=4&weight=2&price=10 etc and the
second set of parameters after the second "?" is ignored by the
browser.

At least that's my understanding (I could be wrong).

I guess it would work if I could remove the first set of params. But
it looks like I will need to do a redirect_to. I was thinking there
might be a cleaner way.

Sorry it is a bit convoluted...

Thanks!
PJ

On Jan 20, 4:00 pm, Hassan Schroeder <[email protected]>
wrote:
> On Fri, Jan 20, 2012 at 12:18 AM, PierreW <[email protected]> wrote:
> > Sorry I did not give the context: these links are used by another,
> > external app (say app B). A user of app B can trigger the creation of
> > a record in App A, and it needs to pass some default parameters.
>
> OK, so to make sure I understand:
>
> app B has a link to  appA/foos/new?size=4&weight=2 -- correct?
>
> and then appA's foos `create` action should include those additional
> parameters passed to `new`?
>
> If so, there's no reason you couldn't conditionally add hidden inputs
> to your `new` form to be processed as part of the `create`.
>
> Please let me know if I'm totally off base on my understanding :-)
>
> --
> Hassan Schroeder ------------------------ 
> [email protected]http://about.me/hassanschroeder
> twitter: @hassan

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to