Wil Shipley WWDC Student Presentation Feeling JavaScripty in Ruby
Nov 06

Rails: requires, class loading, and magic

Tech Add comments

James Duncan Davidson has written up a frustrating experience where he learned Rails Sometimes Eats Class Load Errors.

After the trouble debugging the issue, James suggests:

Use require what you need where you need it. I tend to do this in my code all the time, probably from the habit of using include and import in other languages which are a bit pickier about such things. But, from now on, I’ll be prompting others to do this as well in Ruby, especially when using Rails. Don’t trust environment.rb. There’s too much magic there.

It is interesting to hear this, when on the other hand you learn about the new dependency management in Edge Rails.

Edge Rails lets you put code in yourappproject/mystuff/foo.rb in the package Mystuff::Foo and it is all loaded for you. This means that you can do LESS require-ing.

However, there does seem to be a bit too magic going on here, and I often forget the order of when things are loaded, which can be very painful indeed.

I wonder if someone has written up the dependency cycle of Rails so we can print it and put it on the wall :)

2 Responses to “Rails: requires, class loading, and magic”

  1. lovelove Says:

    “MF WOW CDK and OF WOW CDK will be activated at a sale within 40 days! Buy more
    ,the price will be much lower.”
    game

  2. lovelove Says:

    “MF WOW CDK and OF WOW CDK will be activated at a sale within 40 days! Buy more
    ,the price will be much lower.”
    game

Leave a Reply

Spam is a pain, I am sorry to have to do this to you, but can you answer the question below?

Q: What are the first four letters in the word British?