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

thank you very much..

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.

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. (~_~!)

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.

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.