I set a cookie but otherwise don't really have any variables that
cross.  I also have other forms that are even simpler (not even the
cookie) and they blank out as well. I also checked my views, no
variables are the same. Thanks for your help.


class Qcsubmissions::SetupDatabasesController < ApplicationController
  layout 'qcsubmissions'

  def create
    if params[:setup_database]['page'] == "index"
      #Set variables and set cookies
      sCode = params[:setup_database]['DatabaseCode']
      cookies[:code] = sCode
      #determine if code is queriable or not
      db = SetupDatabase.new(sCode, current_user.name)
      bExist = db.newDatabase()
      if bExist then
        redirect_to :action => :query
      else
        redirect_to :action => :add
      end
    #Add new, Product and Action Tables
    elsif params[:setup_database]['page'] == "add"
      #Set variables and set cookies
      sCode = params[:setup_database]['DatabaseCode']
      cookies[:code] = sCode
      #determine if code is queriable or not
      db = SetupDatabase.new(sCode, current_user.name)
      bExist = db.newDatabase()
      if bExist == false
        if validateProductTable(params[:setup_database],
params[:dbType], params[:interface])
              db.addProduct(params[:setup_database]['DatabaseName'],
params[:dbType], params[:interface])
              redirect_to :action => :query
              db.emailSD(current_user.id)
            else
              render :action => :add
            end
          else
            render :action => :add
          end
        else
          render :action => :add
        end
      else
        flash[:error] = "<div>Submission Not Accepted: Database
already exists.</div>"
        redirect_to :action => :query
      end
    end
  end

  def query
    #variables to pass to the view
    @code = cookies[:code]
    @db = "development"
  end

  def add
    #variables to pass to the view
    @code = cookies[:code]
  end

  def index
  end

  def show
    redirect_to :action => :index
  end

  #Validate Insert into Product Table
  def validateProductTable(formParams, formType, interface)
    bOK = true
    fmessage = Array.new
    if formParams['DatabaseName'].blank?
      bOK = false
      fmessage << "<div>Database Name is required.</div>"
    end
    if formParams['DatabaseCode'].blank?
      bOK = false
      fmessage << "<div>Database Name is required.</div>"
    end
    if formType.blank?
      bOK = false
      fmessage << "<div>Database Type must be selected.</div>"
    end
    if interface.blank?
      bOK = false
      fmessage << "<div>Interface must be selected.</div>"
    end
    if fmessage.length > 0
      flash[:error] = fmessage
    end
    return bOK
  end
end

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to