Passing params FROM Views TO Controllers -- using form_for, form_tag/select_tag

Hello,

I have 3 methods in a controller (index, choose_table and profile).

The index method simply displays a form_for template where the user can choose a database name to use and pass the information to the action :choose_table the params[:db][:type].

The choose_table action then displays another form_for template where the user chooses a table name that will be passed to the the action :profile as params[:table] [:type].

At the profile method, I then eval the expression using @db_table = eval("#{@db_env}" + "::" + "#{@table_type}") so I can do something like @db_table.find(:all) which evaluates to Databasename::User.find(:all) or a @db_table.paginate(:page etc, etc) which evaluates to something like Databasename:User.paginate(:page etc, etc).

The point is to give the user the ability to choose the database name and table using Dr. Nic's Multiple Connections using the call format to Object::ModelName.methodname(....).

My question is how do I pass FROM the views TO the controller and retain information like the params[:db][:type] and params[:table][:type] which I lose when coming from a view or views.

What technique can I use to pass back to the controller params[:db] [:type] and params[:table][:type] from the views choose_table and profile in this cases, using form_for and form_tag/select_tag form methods. Passing these

params the other way around (from the controller to the view) is not a problem. BTW, I am unable to use session database persistence because I am dealing with non-standard legacy Oracle databases/tables.

Thanks rgtorre

Hello,

At the profile method, I then eval the expression using @db_table = eval("#{@db_env}" + "::" + "#{@table_type}")

I would use constantize. What you've got there leaves you wide open.

so I can do something like @db_table.find(:all) which evaluates to Databasename::User.find(:all) or a @db_table.paginate(:page etc, etc) which evaluates to something like Databasename:User.paginate(:page etc, etc).

The point is to give the user the ability to choose the database name and table using Dr. Nic's Multiple Connections using the call format to Object::ModelName.methodname(....).

My question is how do I pass FROM the views TO the controller and retain information like the params[:db][:type] and params[:table][:type] which I lose when coming from a view or views.

What technique can I use to pass back to the controller params[:db] [:type] and params[:table][:type] from the views choose_table and profile in this cases, using form_for and form_tag/select_tag form methods. Passing these

hidden_field_tag? or make your routes interesting, ie /profile/foo/bar
runs the profile action for database foo and table bar.

params the other way around (from the controller to the view) is not a problem. BTW, I am unable to use session database persistence because I am dealing with non-standard legacy Oracle databases/tables.

You could still use the session if you wanted (eg with cookiestore).
And the fact that you tried to use the flash indicates your session is
working fine (the flash is stored in the session).

Fred