당신이 Mac OS X를 사용하거나 Linux 계열을 사용하고, Rails 프로그램 개발자라면 이 포스트가 도움이 될 것이다.
최신 plugin을 설치하기 위해서 gem update를 실시하였고 Rails를 실행하기 위해 ruby scrtipt/server를 실행하였다면 아래와 같은 문제를 겪게 될 것이다.
이 문제는 gem update를 이용하면 이전 버전을 계속 보관하고 있어서 사용하는 버전을 찾는데 생기는 혼란으로 보여진다. 실제 rubyforege에서도 이와 같은 문제를 fix한 글이 있다. 아래 링크 참조
http://rubyforge.org/tracker/?func=detail&aid=16145&group_id=1306&atid=5145
/Library/Ruby/Gems/1.8/gems/gem_plugin-0.2.3/lib/gem_plugin.rb:138:in `load': undefined local variable or method `init_rb' for #<GemPlugin::Manager:0x105d9e8> (NameError)
from /Library/Ruby/Site/1.8/rubygems/source_index.rb:203:in `each'
from /Library/Ruby/Site/1.8/rubygems/source_index.rb:203:in `each'
from /Library/Ruby/Gems/1.8/gems/gem_plugin-0.2.3/lib/gem_plugin.rb:112:in `load'
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:278
from /usr/bin/mongrel_rails:19:in `load'
from /usr/bin/mongrel_rails:19
이 문제의 해결 방법은 gem_pllugin.rb파일을 수정해줘야 한다.
sudo vi /Library/Ruby/Gems/1.8/gems/gem_plugin-0.2.3/lib/gem_plugin.rb 로 파일을 열어서 아래 부분을 수정하면 된다.
# Previously was set wrong, we already have the correct gem path!
#gem_dir = File.join(Gem.dir, "gems", "#{gem.name}-#{gem.version}") (주석으로 처리할 부분)
gem_dir = File.join(Gem.dir, "gems", path)
-
- require File.join(gem_dir, "lib", gem.name, "init.rb") (주석으로 처리할 부분)
+ init_rb = File.join(gem_dir, "lib", gem.name, "init.rb")
+
+ require init_rb if File.readable?(init_rb)
@gems[gem.name] = gem_dir
end
end레일스의 라우트는 매우 엄격하고 유연하며 실용적이지만, 어렵다 ㅡㅡ;
creates seven different routes in your application:
| HTTP verb | URL | controller | action | used for |
|---|---|---|---|---|
| GET | /photos | Photos | index | display a list of all photos |
| GET | /photos/new | Photos | new | return an HTML form for creating a new photo |
| POST | /photos | Photos | create | create a new photo |
| GET | /photos/1 | Photos | show | display a specific photo |
| GET | /photos/1/edit | Photos | edit | return an HTML form for editing a photo |
| PUT | /photos/1 | Photos | update | update a specific photo |
| DELETE | /photos/1 | Photos | destroy | delete a specific photo |
For the specific routes (those that reference just a single resource), the identifier for the resource will be available within the corresponding controller action as params[:id].
출처
http://guides.rubyonrails.org/routing_outside_in.html