# Field observer parameters

**URL:** <https://www.ruby-forum.com/t/field-observer-parameters/139215>\
**Category:** Rails\
**Created:** [June 2, 2008, 12:04am UTC](https://www.ruby-forum.com/t/field-observer-parameters/139215 "2008-06-02T00:04:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mex23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@mex23](https://www.ruby-forum.com/u/mex23)\
**Post date:** [June 2, 2008, 12:04am UTC](https://www.ruby-forum.com/t/field-observer-parameters/139215/1 "2008-06-02T00:04:18Z")

</div>

How do I pass more than one parameter through :with in a field observer?

Here is my code:

\< %= observe\_field(â€™article\_image\_idâ€™,  
:frequency =\> 0.25,  
:update =\> â€˜image\_previewâ€™,  
:url =\> { :action =\> :image\_preview },  
:with =\> â€œâ€˜id=â€™+valueâ€) %\>

I need to pass also another value. How should I modify the code?

Thanks

Stefano

---

<div class="post-metadata">

**Author:** ![mex23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@mex23](https://www.ruby-forum.com/u/mex23)\
**Post date:** [June 2, 2008, 1:52am UTC](https://www.ruby-forum.com/t/field-observer-parameters/139215/2 "2008-06-02T01:52:44Z")

</div>

You’re just building up a string that represents the query string for  
the http request using javascript,so add  
‘&my\_new\_param=’+my\_param\_value

On Jun 1, 6:04 pm, Stefano B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![mex23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@mex23](https://www.ruby-forum.com/u/mex23)\
**Post date:** [June 2, 2008, 6:12am UTC](https://www.ruby-forum.com/t/field-observer-parameters/139215/3 "2008-06-02T06:12:47Z")

</div>

I’d like to add that you may need to encode the parameter

:with =\> “‘myparam=’+encodeURIComponent($F(‘form\_field\_id’))  
+’&param2=’+encodeURIComponent($F(‘form\_field\_id’))”

---

<div class="post-metadata">

**Author:** ![mex23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@mex23](https://www.ruby-forum.com/u/mex23)\
**Post date:** [June 2, 2008, 9:03am UTC](https://www.ruby-forum.com/t/field-observer-parameters/139215/4 "2008-06-02T09:03:17Z")

</div>

On Jun 2, 5:12 am, rubynuby [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’d like to add that you may need to encode the parameter
> 
> :with =\> “‘myparam=’+encodeURIComponent($F(‘form\_field\_id’))  
> +‘&param2=’+encodeURIComponent($F(‘form\_field\_id’))”

You should indeed be doing that. There’s some other ways of doing  
this, I wrote about it over at

> **[:with or :without you: link\_to\_remote's mysterious parameter - Space Vatican](https://www.spacevatican.org/2008/5/17/with-or-without-you-link_to_remote-s-mysterious-parameter/)**
>
> One of the nice things about Rails is that it makes it really easy to get off the ground with Ajax, thanks to the link\_to\_remote helper (and all the …

Fred

---

<div class="post-metadata">

**Author:** ![mex23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@mex23](https://www.ruby-forum.com/u/mex23)\
**Post date:** [June 2, 2008, 2:03pm UTC](https://www.ruby-forum.com/t/field-observer-parameters/139215/5 "2008-06-02T14:03:01Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

On Monday 02 June 2008 09:02:15 Frederick C. wrote:

> I wrote about [link\_to\_remote :with] over at

> **[:with or :without you: link\_to\_remote's mysterious parameter - Space Vatican](https://www.spacevatican.org/2008/5/17/with-or-without-you-link_to_remote-s-mysterious-parameter/)**
>
> One of the nice things about Rails is that it makes it really easy to get off the ground with Ajax, thanks to the link\_to\_remote helper (and all the …

That’s the best treatment of the subject I’ve ever seen!

Thanks,  
Sheldon.  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIQ+EepGJX8XSgas0RAg49AJ97nRSPPAHCEUD56Hya8G6EmrBoIQCgkKtT  
F5hIUF1RdF2Cst30jyuQ/Jo=  
=kmsd  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![mex23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@mex23](https://www.ruby-forum.com/u/mex23)\
**Post date:** [June 3, 2008, 8:53pm UTC](https://www.ruby-forum.com/t/field-observer-parameters/139215/6 "2008-06-03T20:53:40Z")

</div>

Many thanks guys!
