Non model cascading selects

In my model I have a city_id. ON the form I am using a cascading select
to select the state, which then does a remote_submit to get the list of
cities (and hence the city_id) for the selected state. The problem that
I am having is that if I make a selection, hit SUBMIT and validation
fails, the original selected state/city is now reset (ie, the values
aren’t saved). Since they aren’t part of the model do I assign them to
the flash or session? How do you set the initial values from these
hashes?

Thanks

initialize it in the controller and the re-assign it in your remote
action in the controller, form the params

def create

do your stuff

@selected_city = params[:city]
@selected_city ||= City.first
render :action => show
end

then you can use @selected_city when you come back to the view

<%= select ( …, :selected => @selected_city %>

hope it helps

j

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs