Skip to content

Instantly share code, notes, and snippets.

@kidach1
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kidach1/32bad1993c7d8160f7a6 to your computer and use it in GitHub Desktop.
Save kidach1/32bad1993c7d8160f7a6 to your computer and use it in GitHub Desktop.
Gem、Railtieプラグイン、Engine(full/mountable)の違いとそれぞれの基礎情報 ref: http://qiita.com/kidachi_/items/565c2c077ae8d15fe3a8
# Pick the frameworks you want:
require "active_model/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
bundle gem <gem_name> -t
module MyPlugin
class Railtie < Rails::Railtie
# config.my_plugin = ...
# initializer "my_lugin.set_configs" ...
end
end
$ rake routes
Prefix Verb URI Pattern Controller#Action
my_engine /my_engine MyEngine::Engine
Routes for MyEngine::Engine:
foo GET /foo(.:format) my_engine/bar#foo
module Rails
class Railtie
end
class Engine < Railtie
end
class Application < Engine
end
end
rails plugin new <plugin_name>
rails plugin new <engine_name> --full
rails plugin new <engine_name> --mountable
$ rake routes
Prefix Verb URI Pattern Controller#Action
foo GET /foo(.:format) bar#foo
MyEngine::Engine.routes.draw do
get 'foo' => 'bar'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment