H Phillip,
I’m probably doing something wrong somewhere…
The only way I’ve managed to get the values in and out is like this:
Here’s my original ‘index.htm.erb’ form code
<% form_tag(:action => “confirm_form”) do %>
checkin:<%= text_field_tag("checkin") %>
checkout:<%= text_field_tag("checkout") %>
nights:<%= text_field_tag("nights") %>
<%= submit_tag("next") %>
<% end %>
And here’s the controller code from ‘booking_form_controller.rb’
def confirm_form
session[:formStore1] = params[:checkin]
session[:formStore2] = params[:checkout]
session[:formStore3] = params[:nights]
end
and then my ‘confirm_form.html.erb’ view code looks like this:
Checkin: <%= @checkin = session[:formStore1] %>
Checkout: <%= @checkout = session[:formStore2] %>
Nights: <%= @nights = session[:formStore3]%>
Which did all seem rather verbose.
I’d assumed I could pass the key value pair into a hash stored in the
Session, then reference the key to pull out the value. I think I’m
probably just struggling with the syntax a little - maybe I’m not
understanding how the the form results are being passed into my
confirm_form method. I’m not sure really
But what I have works, just doesnt seem right or very nice to me. I
couldnt get an joy trying to pass the key and values from the from into
an array as you described. It kept spitting out the key and value.
Thanks, Alex
Phillip K. wrote:
On Jan 16, 2008, at 12:12 AM, Alex Counsell wrote:
cant make head-nor-tail of it.
Hi Alex,
You should be able to do this
session[:my_array] = Array.new
session[:my_array] << an_element
copy_of_element = session[:my_array][0]
Does that not work?
Peace,
Phillip