How does the lib folder work in Rails 3? In Rails 2.x you would add require statements in application.rb, fx: /lib blip.rb # blip.rb puts "BLIP" # application.rb ... require ''blip'' --- But using the same approach doesn''t work in Rails 3. How do I configure this so that blip.rb is loaded when I start Rails, fx using $ rails s ? Haven''t been able to find any info on this in the blogosphere... Thanks! -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
OK, it seems it works using autoload, being lazy loaded when accessed. But what if I want to force it to be loaded when rails starts? Appending a require ''blip'' in application.rb I am told no such file exists!? Would I have to insert it in an initializer? # lib/blip.rb puts "Blip loaded!" class Blip def self.blip puts "Blip Blip!" end end $ rails console Creating Devise.mapping methods for user Loading development environment (Rails 3.0.0.beta3) ruby-1.9.2-head > Blip.blip Blip loaded! Blip Blip! => nil ruby-1.9.2-head > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Yes, it worked by inserting the require statements in the initializers. On May 12, 12:00 pm, Kristian Mandrup <kmand...@gmail.com> wrote:> How does the lib folder work in Rails 3? > > In Rails 2.x you would add require statements in application.rb, fx: > > /lib > blip.rb > > # blip.rb > puts "BLIP" > > # application.rb > ... > require ''blip'' > --- > > But using the same approach doesn''t work in Rails 3. How do I > configure this so that blip.rb is loaded when I start Rails, fx using > $ rails s ? > > Haven''t been able to find any info on this in the blogosphere... > > Thanks!-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.