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

Reply via email to