mirror of
https://github.com/discourse/discourse-rewind.git
synced 2025-07-06 22:02:12 +00:00
DEV: Add rails engine and file paths to skeleton (#29)
This commit is contained in:
parent
f19d9a8aa6
commit
8421cf6d72
11
app/controllers/my_plugin_module/examples_controller.rb
Normal file
11
app/controllers/my_plugin_module/examples_controller.rb
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module ::MyPluginModule
|
||||||
|
class ExamplesController < ::ApplicationController
|
||||||
|
requires_plugin PLUGIN_NAME
|
||||||
|
|
||||||
|
def index
|
||||||
|
render json: { hello: "world" }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
8
config/routes.rb
Normal file
8
config/routes.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
MyPluginModule::Engine.routes.draw do
|
||||||
|
get "/examples" => "examples#index"
|
||||||
|
# define routes here
|
||||||
|
end
|
||||||
|
|
||||||
|
Discourse::Application.routes.draw { mount ::MyPluginModule::Engine, at: "my-plugin" }
|
9
lib/my_plugin_module/engine.rb
Normal file
9
lib/my_plugin_module/engine.rb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module ::MyPluginModule
|
||||||
|
class Engine < ::Rails::Engine
|
||||||
|
engine_name PLUGIN_NAME
|
||||||
|
isolate_namespace MyPluginModule
|
||||||
|
config.autoload_paths << File.join(config.root, "lib")
|
||||||
|
end
|
||||||
|
end
|
10
plugin.rb
10
plugin.rb
@ -9,4 +9,12 @@
|
|||||||
|
|
||||||
enabled_site_setting :plugin_name_enabled
|
enabled_site_setting :plugin_name_enabled
|
||||||
|
|
||||||
after_initialize {}
|
module ::MyPluginModule
|
||||||
|
PLUGIN_NAME = "discourse-plugin-name"
|
||||||
|
end
|
||||||
|
|
||||||
|
require_relative "lib/my_plugin_module/engine"
|
||||||
|
|
||||||
|
after_initialize do
|
||||||
|
# Code which should run after Rails has finished booting
|
||||||
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user