Getting parameter?

Hello RoR developers

do you know how can I get parameter from selection to method from out of
form object?
I have selection in view page, I have method in controller and I want to
get parameter from selection but selection is not in form. how can I get
it ??

if you have sample code pls write it with your commend.

thank you very much for any help

From http://api.rubyonrails.org/ :
select(object, method, choices, options = {}, html_options = {})

that’s the basic select tag used to interact with a model…here’s one
of my select forms in a view (inside a form tag of course)

<%=select(:record, :station_id, Station.find(:all).collect {|p|
[ p.name, p.id ] }, { :selected => @station.id }) %>

In this example I’m trying to set the station_id method of my record
object. I want to be able to select from all my stations
(Station.find(:all)) then we collect those stations into a set option
tags basically - the interior of the collect takes the text then the
value of the option tag ( {|p| [p.name, p.id]} ).

Ok so that’s the select tag. Then we access the info from the select
tag the same way we access any form parameter in the controller:

params[:object][:method]

or in my example:

params[:record][:station_id]

this will get you the value of the option tag you setup in your select
tag (be careful to get the correct info into the value and text of the
option tags)

Hope that helps.

T

On Feb 20, 8:07 pm, Ibrahim D. [email protected]

that’s the basic select tag used to interact with a model…
the basic select_tag object is the form s object right ???

Ok so that’s the select tag. Then we access the info from the select
tag the same way we access any form parameter in the controller:

I m trying to get params[:] from out of form. there is no form in my
view page.

thank you very much again for your comment.

thank you very much…

I have solution for you.

Change your javascript to be storing your wanted params to cookies or
session, you can use AJAX. I dont have this script but i have read about
it. so you can access that params in your view without form or
select_tag. It was 3 days your problem posted without solution, it still
continoes up to 7 days your should pay rails consultant for it. (~_~!)

~~~~~~~~~~~~~~
Reinhart Ariando
YM:Booking2Heaven
WEB:teapoci.blogspot.com
~
~~~~~~~~~~~~~

actually I have many suggestions but I couldnt use any.
ajax is another solution but nobody around me knows programming. no
chance to consult with anyone. that s why I ask here. I don t have so
much time left either. today I need to finish it. quick and certain
solutions are preferred. :slight_smile:

thank you very much for your suggestion.

hey…why you not convert your js to your controller and store it in
session you can make new def method for it or new attribute, it think
it will be help full and make it has array or hash, then you can call
freely in your view.

I just wanna ask whether i can call a function from my view and pass
some parameters within. For the example, i have function setDirections
that when i call using “setDirections(“new york”, “boston”, “en_US”);”
command run smoothly… but what i need is to replace “new york” and
“boston” with session[:address1] and session[:address2]…
Do you have any opinion about this…???

Regards,

Adi

Visit Indonesia 2008 wrote:

hey…why you not convert your js to your controller and store it in
session you can make new def method for it or new attribute,

could you tell me your suggestion detailed? I couldn t get it well.

thank you Ariando,you are so philanthropic.