Forum: Ruby on Rails Two classes in one program.

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.
Acb42a0e563bffaaf94ea2d07fbb1d8e?d=identicon&s=25 Tushar Gandhi (tushar_gandhi)
on 2009-01-15 14:27
Hi,
 Is it possible to write two class in one controller?
e.g:-

class ApplicationController < ActionController::Base
  def abc
  end
end
class Hash
 def xyz
 end
end

How it will work?

Thanks,
Tushar.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-01-15 14:42
(Received via mailing list)
On 15 Jan 2009, at 13:27, Tushar Gandhi wrote:

> def xyz
> end
> end
>

A file can define as many classes as you want. Rails' automatic
loading of files for you will only be able to locate a class if it is
in the file with the appropriate name.

Fred
This topic is locked and can not be replied to.