Forum: Ruby on Rails Hello! I'm getting

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F0f940aa9dd906a7430ed72137fbd343?d=identicon&s=25 cory moto (clawson)
on 2007-01-31 00:06
an uninitialized constant ApplicationController (Name Error)

Any idea what can be causing this?  I have application.rb.  Here is my
amin.controller.rb that is causing the error.


**********************************************************

class AdminController < ApplicationController

  before_filter :authorize

  def index
    list
    render :action => 'list'
  end

  # GETs should be safe (see
http://www.w3.org/2001/tag/doc/whenToUseGet.html)
  verify :method => :post, :only => [ :destroy, :create, :update ],
         :redirect_to => { :action => :list }

  def list
    @account_pages, @accounts = paginate :accounts, :per_page => 10
  end

  def show
    @account = Account.find(params[:id])
  end

  def new
    @account = Account.new
  end

  def create
    # account_number = 2 test account_number to make sure it wasn't null
    @account = Account.new(@params[:account])
    if @account.save
      flash['notice'] = 'Account was successfully created.'
      redirect_to :action => 'list'
    else
      render :action => 'new'
    end
  end

  def edit
    @account = Account.find(params[:id])
  end

  def update
    @account = Account.find(params[:id])
    if @account.update_attributes(params[:account])
      flash[:notice] = 'Account was successfully updated.'
      redirect_to :action => 'show', :id => @account
    else
      render :action => 'edit'
    end
  end

  def destroy
    Account.find(params[:id]).destroy
    redirect_to :action => 'list'
  end
end
***********************************************************************

I am also getting an error when the 'create' method is called.

************************************************************************

ActiveRecord::StatementInvalid (Mysql::Error: #23000Column
'account_number' cannot be null: INSERT INTO accounts (`city`, `name`,
`zip`, `hashed_password`, `contact_phone`, `technician`,
`contact_email`, `executive`, `account_number`, `address`,
`contact_name`, `state`) VALUES(NULL, NULL, NULL,
'11ab3a5d9ae5e9b03b532c949a2508139a4c1652', NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL))

*******************************************************************************


It looks to me like the only thing that it is accepting is the
hashed_password field.  I've put values into all of the fields. When I
click create this is what I get.
10a8337cf8879d37affd54e1cab4d79e?d=identicon&s=25 Andy Koch (Guest)
on 2007-01-31 18:39
(Received via mailing list)
I might guess that "account_number" is set as not-null in the MySQL data
  structure.  As it looks to be reporting an error from MySQL not from
Rails.

Not sure about the Name Error, I would look at the application.rb make
sure that class is error free.  Perhaps try poking around with the
console or some functional tests.

/ak

Cory Me schrieb:
290fd6795af59caa5da38957340bc857?d=identicon&s=25 David Harkness (nullserver)
on 2007-01-31 22:51
You'll get  "uninitialized constant ApplicationController (Name Error)"

If you try running admin_controller.rb as a stand alone application.

I've seen people try and do this through RadRails.
This topic is locked and can not be replied to.