º¸³½»ç¶÷: Phillip Koebbe <phillipkoe...@gmail.com>
³¯Â¥: Sat, 20 Sep 2008 18:51:26 -0700 (PDT)
ÇöÁö½Ã°£: 2008³â9¿ù21ÀÏ(ÀÏ) ¿ÀÀü10½Ã51ºÐ
Á¦¸ñ: Rails 2.1 and const_missing
I was using MMC in a rake task in Rails 2.0.2 successfully, but when I
recently upgraded to Rails 2.1.1, the rake task failed with the error uninitialized constant {const_id}
A little bit of digging turned up a couple of things.
1) There is a type in connected.rb at line 20:
raise NameError.new("uninitialized constant \{const_id}") unless
Notice the backslash where a pound should be. The reason this was
2) ActiveSupport::Inflector.constantize was changed between 2.0.2 and
def constantize(camel_cased_word)
Object.module_eval("::#{$1}", __FILE__, __LINE__)
Notice that it's doing a regex match on the format of camel_case_word,
def constantize(camel_cased_word)
constant = Object
Notice here that if the constant is not defined, the object's
raise NameError.new("uninitialized constant #{const_id}") unless
to
return unless target_class
I then ran my rake task in Rails 2.1.1 and it seemed to work
Peace,
¸Þ½ÃÁö¸¦ °Ô½ÃÇÏ·Á¸é ±×·ì¿¡ °¡ÀÔÇØ¾ß ÇÕ´Ï´Ù.
¸Þ½ÃÁö¸¦ °Ô½ÃÇÏ·Á¸é ¸ÕÀú ÇØ´ç ±×·ì¿¡ °¡ÀÔÇÏ¼Å¾ß ÇÕ´Ï´Ù.
°Ô½ÃÇϱâ Àü¿¡ °¡ÀÔ ¼³Á¤ ÆäÀÌÁö¿¡¼ ´Ð³×ÀÓÀ» ¾÷µ¥ÀÌÆ®Çϼ¼¿ä.
¸Þ½ÃÁö¸¦ °Ô½ÃÇÒ ¼ö ÀÖ´Â ±ÇÇÑÀÌ ¾ø½À´Ï´Ù.
| ||||||||||||||