# Validation doesn't work (ActiveRecord::BaseWithoutTable)

**URL:** <https://www.ruby-forum.com/t/validation-doesnt-work-activerecord-basewithouttable/147230>\
**Category:** Rails\
**Created:** [August 29, 2008, 5:32pm UTC](https://www.ruby-forum.com/t/validation-doesnt-work-activerecord-basewithouttable/147230 "2008-08-29T17:32:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [August 29, 2008, 5:32pm UTC](https://www.ruby-forum.com/t/validation-doesnt-work-activerecord-basewithouttable/147230/1 "2008-08-29T17:32:53Z")

</div>

Hi,

I understand that the active\_record\_base\_without\_table is supposed to be  
an easy install. So I am not sure why the validation doesn’t work out of  
the box (base\_without\_table.rb attached). No valdn error msgs and it  
takes all values.  
Am I missing any steps?

I am creating a change password page where it compares old\_password with  
the stored password in the database. And then user can change it.

View simply has :old\_password, :new\_password, and  
:new\_password\_confirmation

## The Password controller:

class PasswordsController \< ApplicationController

layout ‘base’

before\_filter :load\_user  
before\_filter :check\_auth

def new  
@password = Password.new

```
 respond_to do |format|
  format.html #new.html.erb
 end

```

end

def change  
puts params  
if !params[:password][:old\_password].blank? or  
!params[:password][:new\_password].blank?  
@old\_password = params[:password][:old\_password]  
@new\_password = params[:password][:new\_password]  
@encrypted\_original = @user.encrypted\_password  
if !@user.compare\_password(@encrypted\_original, @old\_password)  
flash[:notice] = ‘Sorry, we could not find your old password in  
our database. Please enter the old password again’  
else  
@user.encrypted\_password =  
Standards.encrypt\_a\_code(@new\_password)  
@user.save(perform\_validations=false)  
flash[:notice] = ‘Your new password has been saved’  
end  
end  
redirect\_to :action =\> ‘new’  
end  
end

## The Password model:

class Password \< ActiveRecord::BaseWithoutTable  
column :old\_password, :string  
column :new\_password, :string

validates\_presence\_of :old\_password

attr\_accessor :old\_password, :new\_password, :new\_password\_confirmation

validates\_confirmation\_of :new\_password, :message =\> “New password  
should match confirmation”  
validates\_length\_of :old\_password, :new\_password, :minimum =\> 6

end

---

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [August 29, 2008, 5:50pm UTC](https://www.ruby-forum.com/t/validation-doesnt-work-activerecord-basewithouttable/147230/2 "2008-08-29T17:50:02Z")

</div>

The validations will be run when you call .save on your instance of  
Password:

@password.save

David R.

On Fri, Aug 29, 2008 at 10:32 AM, Milton Wong \<
