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. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060213/d21083dd/attachment.html
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/ActionController/Dependencies/ClassMethods.html 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.
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> 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/ActionController/Dependencies/ClassMethods.html > > 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. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >