Created
November 19, 2012 11:11
-
-
Save khoan/4110151 to your computer and use it in GitHub Desktop.
rails eager load app/ directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ruby 1.9.3-p125-perf | |
# Rails 3.2.0 | |
# app/bam/ham.rb | |
module Bam | |
class Ham | |
end | |
end | |
# on rails console | |
# | |
# > Bam::Ham.new | |
# NameError: uninitialized constant Bam | |
# > Ham.new | |
# LoadError: Expected /Users/khoa/workspace/shop2/app/bam/ham.rb to define Ham | |
# from gems/activesupport-3.2.0/lib/active_support/dependencies.rb:503:in `load_missing_constant' | |
# from gems/activesupport-3.2.0/lib/active_support/dependencies.rb:192:in `block in const_missing' | |
# from gems/activesupport-3.2.0/lib/active_support/dependencies.rb:190:in `each' | |
# from gems/activesupport-3.2.0/lib/active_support/dependencies.rb:190:in `const_missing' | |
# from (irb):1 | |
# from gems/railties-3.2.0/lib/rails/commands/console.rb:47:in `start' | |
# from gems/railties-3.2.0/lib/rails/commands/console.rb:8:in `start' | |
# from gems/railties-3.2.0/lib/rails/commands.rb:41:in `<top (required)>' | |
# from script/rails:6:in `require' | |
# from script/rails:6:in `<main>' | |
# | |
# Now it works! | |
# | |
# > Bam::Ham.new | |
# => #<Bam::Ham:0x00000104485170> | |
# How can I achieve this namespaced structure rather than naming everything similar to controllers, helpers? That is: | |
# app/controllers/application_controller.rb | |
class ApplicationController | |
end | |
# app/helpers/bam_helper.rb | |
class BamHelper | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe Bam::Ham.new ?