From: "B. Randy" Date: 2009-04-22T17:12:02+09:00 Subject: Re: Sinatra : examples and FRAME. jonty wrote: > > I don't see the need to use frames, it is just a question of saving your > data in the post method and reading your data in the get > > The get will fetch the current data save it in an instance variable > (@variable) and refer to a template that includes your form which has > an href of '/' and method post > but can also display the current data from the @variable. Hello, '@variable' isn't useful because they aren't global. The global variable like '@@variable_global' could be used in a Web context ? What's happen when many user play with the application ? I've tried to follow your advice in the following code. Yes, I know that I 'm not good with HTML :( I've put comments in the code. I can't show the selected value in the form without reload the page !? Suggestions ? Tkanks. Randy11. ###################################################################### # demo.rb require 'sinatra' # What is it done ? # 1 - The "get '/'" show the form. In the form the method 'POST' is used # and call 'request_list'. # 2 - The "post '/request_list' gets the parameters, save it in session's # variables. # 3 - The "post" redirect to get "'/:start,:end,:type,:where'" which # build the data : "@data", and display again the form. # => PROBLEM : I lost the selected value in the form. I can't set the # default value like : '"} option end # The list of choices. def select_options @start_choice = html_select([ 1, 2, 3, 4]) @where_choice = html_select(%w[Here There Nowhere Somewhere]) @type_choice = html_select(%w[A B C D E F G]) # If nothing is displayed like : "", the last thing, here : # '@type_choice', is displayed. "" end end # All HTML pages here. __END__ @@ main_html Test of Sinatra.

Show some data.

You must RELOAD the page to see the previous selected values after the 'SEND' !!! ???

<%= select_options() %>
Make your choice Display all

Show all data selected.

<%= @data%>
###################################################################### -- Posted via http://www.ruby-forum.com/.