Forum: Ruby on Rails Do I need separate file for each model

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.
A77a8b18452aa37499ff16dd24c4a09e?d=identicon&s=25 M. Utku Altınkaya (Guest)
on 2006-02-13 09:00
(Received via mailing list)
Hi,

I have some models in a file named genel. When I try to use one of the
classes in  my controller rails raises an error telling classname.rb is
not forund even the file is required already.

require "genel"
require "hesaplar"

class HesaplarController < ApplicationController
  def yeni_firma
    @emlak_firmasi = EmlakFirmasi.new
    @sehirler = Sehir.find_all
  end
end

The odd thing is it is working once when I restart webrick, and after
hitting refresh it raises exception again. Why it is insisting to load
classname.rb, isn't it poıssible to use custom filenames for models when
you do not use scaffolding etc.
5a47f5f40df9e9696ca077519c904e90?d=identicon&s=25 unknown (Guest)
on 2006-02-13 12:31
(Received via mailing list)
Hello,

On Mon, Feb 13, 2006 at 10:00:23AM +0200, M. Utku Altınkaya wrote:
> Hi,
>
> I have some models in a file named genel. When I try to use one of the classes in  my 
controller rails raises an error telling classname.rb is not forund even the file is 
required already.
>
> require "genel"
> require "hesaplar"
>

You should not use require. Rails has its own dependency tracking
system. Use

class HesaplarController < ApplicationController

  model :genel, :hesaplar

  def yeni_firma
     @emlak_firmasi = EmlakFirmasi.new
     @sehirler = Sehir.find_all
  end
end

See
http://api.rubyonrails.com/classes/ActionControlle...

Regards,

--
Damien MERENNE   <dam@cosinux.org>
http://www.cosinux.org/blogs/dam/

When Chuck Norris sends in his taxes, he sends blank forms and includes
only a picture of himself, crouched and ready to attack.
Chuck Norris has not had to pay taxes, ever.
A77a8b18452aa37499ff16dd24c4a09e?d=identicon&s=25 M. Utku Altınkaya (Guest)
on 2006-02-13 12:51
(Received via mailing list)
I do not know how to thank you Damien, I was just stuck, I appreciate
your
help.

----- Original Message -----
From: "Damien MERENNE" <dam@bigmonk.cosinux.org>
To: <rails@lists.rubyonrails.org>
Sent: Monday, February 13, 2006 1:31 PM
Subject: Re: [Rails] Do I need separate file for each model
This topic is locked and can not be replied to.