From: David Vallner Date: 2006-12-17T04:48:48+09:00 Subject: Re: binding input elements to params and sessions too --------------enig2F9EEE53962465152156985C Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable henkvantijen@gmail.com wrote: I'll leave the usual redirect to the RoR lists to someone with a canned speech for that, so here goes. Firstly, I think the views have access to the request object. Also, the controller "preparing data" for the view is a common pattern for web frameworks. > So perhaps what I am saying is, lets use a :binding_type key, that > defaults to active record: >=20 I don't think that information belongs to the view. A view template should be oblivious to the controller and model technology, or even to the fact it's used in a web framework with sessions and request parameters. That way, you could technically use (even if the probability of that happening is minuscule) the same template in a non-Rails application as long as the instvars of its evaluation context get appropriately set. Besides, it's even more verbose than just setting the instvars in the controller. If you do that too often, do something like this in your configuration / environment / whatever (been a while since I touched Rails) files: class ActionController::Base def autoregister_params(*args) keys =3D args.empty? ? params.keys : args # Call me old-fashioned, but I like this better than each ;P for key in keys instance_variable_set('@#{key}', params[key]) end end end And then in your controller just use autoregister_params(), or for your example, autoregister_params(:stocks, :indexes, :rates) (to avoid cluttering the instvar namespace with things you only need in the controller.) Or, if very lazy / DRY-addled, I'm sure there's some AoP -ish meta voodoo or Rails hook to cause autoregister_params to be called for each request. David Vallner --------------enig2F9EEE53962465152156985C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MingW32) iD8DBQFFhE2by6MhrS8astoRAn7NAJ0R6y71ousqixS9pl3oe9uT1lnG5QCeI3zW 6t/9V3hri6pIQ6bOLn1uGsk= =N5mZ -----END PGP SIGNATURE----- --------------enig2F9EEE53962465152156985C--