Hello! I'm getting

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.

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:

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 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