[Ruby] Preserving State
ben wiseley
wiseleyb at gmail.com
Tue Dec 5 15:25:08 PST 2006
Well - ugly urls allow people share search results - but bosses will be
bosses...
You could do this all via form posts (so pass the ugliness via post using
hidden fields) with links that submit the form. You get all the usual
garbage that goes along with posts when people hit refresh ("Are you
sure...yadda yadda"). Then just pass back the new values with a @someobject
and reset the hidden form via <%=hidden_field "someobject","somevalue" %> -
Rails is smart if you use the same object names (i.e. @someobject =
"someobject") it'll do the value resets for you. Form helpers actually make
this not so bad.
You could use flash to pass the values back to the view but that's abusing
what flash is meant for and will bite you down the road (because it should
be used for notifying users of errors, alerts, etc.) I actually think it
might be session based as well - never checked that though.
You could do this via sessions, save yourself a bunch of headaches and live
with the memory hit (which would be pretty minimal unless you have gobs of
users - we're doing 1,000,000 hits some days and we have everything + the
kitchen sink in sessions [yah - that's pretty weak - code clean up isn't
high on my bosses list :) ]).
You could be super wizbang and over complicate it and do it all via ajax
(which is the same as doing the form post solution more or less). Rails +
prototype makes doing ajax magic almost too easy.
-ben
On 12/5/06, Neil Moomey <neil at motznik.com> wrote:
>
> Yes, I meant 24 tables, one db.
>
> I'm reading up on sessions as well as flash. Would flash be
> appropriate? I
> like the fact that it's temporary and I can use flash.keep on every page
> until I'm done using it. I would prefer not to use url silliness if
> possible. My boss complained about the ugly urls we are currenly using.
>
> Neil
> _______________________________________________
> Ruby at zenspider.com - Seattle.rb non-commercial list
> http://www.zenspider.com/seattle.rb
> http://www.zenspider.com/mailman/listinfo/ruby
>
More information about the Ruby
mailing list