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
##index method in controller
def index
end
##choose_table method in controller
def choose_table
#flash[:notice] = params[:db][:type] # just tried flash
notice…kludgy…awkward way of
#passing params …
end
##profile method in controller
def profile
@db_table = eval("#{@db_env}" + “::” + “#{@table_type}”)
if params[:client_id].nil? or params[:client_id].empty?
@users = @db_table.paginate(:page => params[:page], :order
=> :client_id, :per_page => 10)
else
@users = @db_table.paginate_by_client_id params[:client_id], :page
=> params[:page]
params[:client_id] = nil
end
end
Database: <%= form.select :type, SourceDb::SOURCE_DB, :prompt => "Select a Database" %>
<%= submit_tag "Continue", :class => "submit" %> <% end %><%= error_messages_for ‘table’ %>
Please Choose a SWOT Table:
<% form_for :table, :url => { :action => :profile } do |form| %>
<%=
form.select :type,
SelectTable::SELECT_TABLES,
:prompt => “Select a Table”
%>
<%= submit_tag “Continue”, :class => “submit” %>
<% end %>
USER <%="#{@db_env}" %>List
Client Id | Field 2 | Field 3 | Field 4 | Field 5 | Field 6 | Field 7 | Field 8 | Field 9 | Field 10 |
---|