I have been working for a whole week on this problem without success, so
I feel that its now time to give up and ask for some help since it seems
that I am obvisouly missing something…
all I want to do is having a form with a dropdown menu. When the user
select a value from the drop down and sumit the value, this value must
be the new ‘active_client’.
Technicaly, when the form is submited from the list page, it calls the
change_active_client action that take care of changing the client’s ID
in the session then returns the control to the list action.
My problem is that when I try to output the value stored in the session,
I get anything but what I expected…
What am I missing?
the simplified version of my code goes like this:
------START_CONTROLER-------
class SpecificController < ApplicationController
def list
@active_client = session[:active_client]
@clients = Client.find_all.collect {|c| [ c.name, c.id ] }
end
def change_active_client
session[:active_client] = params[:client]
redirect_to(:action => “list”)
end
end
------END_CONTROLER-------
------START_VIEW-----------
<%= form_tag (:action => “change_active_client”)%>
<%= select(:client, :id, @clients) %>
<input type="submit" value="Change" />
<%= end_form_tag%>
content of the session: <%=h(session[:active_client])%>
content of the @Active_client: <%=h(@active_client)%>
------END_VIEW---------------
------ABOUT_THE_MODEL------
its a basic table, with ID as a auto increment int and name as a
varchar
-----THE OUTPUT OF ABOVE CODE—
something like: id1 or id2, id3, etc… I want to be able to extract the
name of the client but cant…
This thing is driving me nuts, especially since I am sure this is
something obvious that I am missing!
Thx!