Forum: Ruby on Rails Model is not a class

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Nicholas W. (Guest)
on 2006-04-13 12:25
(Received via mailing list)
I'm trying to specify a model in a controller, but rails gives me
"Account is not a class", where Account is my model name ...

This is my model:

class Account < ActiveRecord::Base

   validates_presence_of :email, :email_confirmation,
     :username, :password, :password_confirmation
   validates_format_of :email,
     :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
   validates_uniqueness_of :username
   validates_length_of :password, :within => 6..20
   validates_confirmation_of :email, :password

   def self.authenticate(username, password)
     find_first(["username=? AND password=?", username, password])


and this is my controller:

class Account::AuthController < ApplicationController

   model :account



I guess the problem is that I'm using a module, my controller is
inside controllers/account/auth_controller.rb.
I'm not able to find the mistake, my model is clearly a class ...
Ideas ?

Nicholas W.

Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
Pete Y. (Guest)
on 2006-04-13 15:34
(Received via mailing list)

Ruby doesn't let you have a class and a module with the same name,
and having class Account::AuthController means that you have a module
called Account containing a class called AuthController.

Convention seems to be that you should have plural module names and
singular model names in this case; i.e. rename your
Account::AuthController to Accounts::AuthController. (Personally that
seems a little dodgy to me, but it seems to be commonly done, and it


Pete Y.
This topic is locked and can not be replied to.