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
# all without using an intermediate variable
@session['selection'] = @form_hash[:selection_name]
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
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
Quoting kuang oon <[EMAIL PROTECTED]>:
> Hi Richard,
> Try working with params for web form data , not @session .
> Make sure you have the the view page and models properly set up. You
> associate a controller action with a page with a rhtml suffix e.g .
> showafterEdit.rhtml
> This is in the folder ...views/controller_name/
> The code segment below is in my file showAfterEdit.rhtml has the
> following embeded ruby commands...
> The rhtml file is fed to an erb interpreter, when you see <%= it
> means that html/javascript stuff is generated for your viewing
> pleasure in a web browser.
> The following generates a lot of localities for a drop down list box
> in your web browser.
> The trick is to remember that web forms data has to be sent back to
> the controller via params.
> The statement below marshalls the data into params
> <%= link_to 'Generate Cupid Key and clinical template', :action =>
> 'generateCupid', :id => @registration %>
>
> After you pick the right selection in your drop down list, you click
> on the link , which collects all your form data and sends it back in
> a convenient hash called params
> You can the access the form variables by the following statement
> which unmarshalls the form data: @registration = Registration.find
> (params[:id])
> if you puts @registration.location_born you get 'London' etc...
>
> I find the following generic statement useful to inspect the .values
> of params/or any variables, it will create an error page with all the
> goodies for your inspection,
> very similar to 'self halt' in smalltalk.
>
> raise params.inspect
>
> The example:
> The .rhtml page
>
> <% thePlaces = GpsController.new.returnLocations %>
> <%= in_place_select_editor_field(:registration,
> :location_born,
> {},
> :select_options => thePlaces) %>
>
> <%= link_to 'Generate Cupid Key and clinical template', :action =>
> 'generateCupid', :id => @registration %>
>
>
> Back at the controller....... the .rb page
>
>
> def generateCupid
> @registration = Registration.find(params[:id])
> # the above is generic rails idiom...stick to it.
> end
>
> HTH
>
> Kuang
>
>
> On 10/01/2007, at 1:11 PM, [EMAIL PROTECTED] wrote:
>
> >
> >
> >
> > Anyone still doing work with RubyRails?
> > I am pegging away at a billing module on the laptop
> > Struggling with select boxes for *hours* and *hours*.
> > There seems to be several ways to do this from using HTML tags
> > directly, to a
> > rails select function. I populate the options with
> > options_for_select and I can
> > render the box but cant seem to get a selection back into a
> > @session variable
> > Anyone got any bombproof code?
> >
> > Thanks
> > Richard Hosking
> > _______________________________________________
> > Gpcg_talk mailing list
> > [email protected]
> > http://ozdocit.org/cgi-bin/mailman/listinfo/gpcg_talk
>
> _______________________________________________
> Gpcg_talk mailing list
> [email protected]
> http://ozdocit.org/cgi-bin/mailman/listinfo/gpcg_talk
>
_______________________________________________
Gpcg_talk mailing list
[email protected]
http://ozdocit.org/cgi-bin/mailman/listinfo/gpcg_talk