Hi Richard,
On 11/01/2007, at 12:52 PM, [EMAIL PROTECTED] wrote:


Thanks Kuangie
Yes I get the data back from the form in params(:form_name) and then try to save
it in @session in the method referred to by the form ie

#in view
start_form_tag :controller => "relevant_controller", :action => "relevant_method"
<select name="select_name">
#form code - I use options_for_select in a helper to populate the options
end_from_tag

#method
@form_hash = params(:select_name) # I cant seem to get this to work at
params(:select_name) is dodgy - the interpreter will interprete that as a params method call to Object with argument :select_name what you really mean is: params[:select_name] which means the value at the key :select_name of the hash called params
# all without using an intermediate variable
@session['selection'] = @form_hash[:selection_name]

For persisting data between actions use flash
e.g. flash[:error]= "program explodes here"
flash.keep(:error) will retain the value for the next request cycle
Note the parentheses aren't square ones.

I use @session to keep track of temporary data - this is deleted with
reset_session when the data is saved to the DB

I still find it hard to grasp the variables and hashes etc in Rails
The "syntactic sugar" ie the variability allowed in syntax tends to blur things
a bit
what syntactic sugar? it is a free world. choose your style , you can surround your arguments with () or choose to ignore parentheses
Ruby is crisper then smalltalk, fewer lines of code to do more stuff.
But be careful to differentiate between square and curvy parentheses
Curly braces are another matter altogether, they are equivalent to a do....end block.
I find the API docs a bit short on actual examples and detailed steps through ther code. Googling may get a result, but often it is on forums with variable
quality code



Richard

Kuang


_______________________________________________
Gpcg_talk mailing list
[email protected]
http://ozdocit.org/cgi-bin/mailman/listinfo/gpcg_talk

Reply via email to