LoginSignup
1
1

More than 5 years have passed since last update.

RailsでのNamespace付きの定数を参照する順番

Last updated at Posted at 2015-10-22

少しイレギュラーとも思えるような参照の仕方をしていたので、メモ

現象

Imageを定義する。
そのあと、Post::Imageを定義していない状態で、Post::Imageを呼び出すと下記のような警告がでるもののImageを参照しにいく。

warning: toplevel constant Image referenced by Post::Image

もちろん、Imageが定義されていない場合は例外が発生する。

requireがされておらず、定数を定義できていなかった場合などのケアレスミスでも、参照されてしまう。
紛らわしいの例外を発生させて欲しい。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1