I''d appreciate any help anyone can give me. I get this same message on
create and update:
<< Error Message >>
ActiveRecord::StatementInvalid in Admin/employees#update
stack level too deep: SELECT * FROM locations WHERE locations.id = 1
LIMIT 1
/app/controllers/admin/employees_controller.rb:39:in `update''
<< Admin::EmployeesController excerpt >>
def new
@locations = Location.find_all
@departments = Department.find_all
@employee = Employee.new
end
def create
@employee = Employee.new(params[:employee])
if @employee.save
flash[:notice] = ''Employee was successfully created.''
redirect_to :action => ''list''
else
render :action => ''new''
end
end
def edit
@locations = Location.find_all
@departments = Department.find_all
@employee = Employee.find(params[:id])
end
def update
@employee = Employee.find(params[:id])
if @employee.update_attributes(params[:employee])
flash[:notice] = ''Employee was successfully updated.''
redirect_to :action => ''show'', :id => @employee
else
render :action => ''edit''
end
end
<< Employee Model >>
class Employee < ActiveRecord::Base
belongs_to :department
belongs_to :location
has_many :versions
belongs_to :role
validates_associated :location, :department, :role, :versions
validates_length_of :first, :within => 1..50
validates_length_of :last, :within => 1..50
validates_length_of :resp, :maximum => 3
validates_format_of :resp_before_type_cast, :with => /([0-9]+)/,
:message=>"Only numbers are allowed in this field."
validates_length_of :office, :within => 0..13
validates_length_of :cell, :within => 0..13
validates_length_of :title, :within => 0..50
validates_format_of :notary_before_type_cast, :with => /[01]/,
:message=>"Must be a 0 or 1."
validates_format_of :active_before_type_cast, :with => /[01]/,
:message=>"Must be a 0 or 1."
end
I''m not sure if its related, but another problem I''m having is
that my
"resp" field, which is set with a maximum of 3 characters,
won''t accept
a 3 character entry. The only way to get it to accept it is to change
the model to :maximum => 4. But then it changes whatever I enter into
my resp field into "127".
==================DISCLAIMER===============================This email may
contain confidential and privileged material for the sole use of the intended
recipient.
Any review or distribution by others is strictly prohibited. If you are not the
intended recipient, please contact the sender and delete all copies of it from
your system.
The sender accepts no responsibility for viruses and it is your responsibility
to scan attachments (if any).
No contracts may be concluded on behalf of the sender by means of email
communications unless expressly stated to the contrary.
==================DISCLAIMER================================