在了解 Moutable之前, 先看这个视频:
http://railscasts.com/episodes/277-mountable-engines
了解Mountable Engines与Full Engines的区别, 看这篇文章:
http://stackoverflow.com/questions/6118905/rails-3-1-engine-vs-mountable-app
当我们使用:
rails plugin new uhoh --mountable我们可以把这个创建好的plugin变成一个gem来使用。
比如我们可以先创建一个rails app
rails new with_engine -T -O -J
编辑Gemfile, 添加以下一行:
gem 'uhoh', :path => '/Users/weston/Downloads/277-mountable-engines/uhoh-after/' #刚才创建的mountable 路径
执行
bundle install vim config/routs.rb
添加以下一行:
mount Uhoh::Engine => "/uhoh", :as => "uhoh_engine"
这样我们就可以使用这个engines了…
If you enjoyed this post, make sure you subscribe to my RSS feed!