Skip to content

Commit 8421cf6

Browse files
DEV: Add rails engine and file paths to skeleton (#29)
1 parent f19d9a8 commit 8421cf6

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
module ::MyPluginModule
4+
class ExamplesController < ::ApplicationController
5+
requires_plugin PLUGIN_NAME
6+
7+
def index
8+
render json: { hello: "world" }
9+
end
10+
end
11+
end

config/routes.rb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
3+
MyPluginModule::Engine.routes.draw do
4+
get "/examples" => "examples#index"
5+
# define routes here
6+
end
7+
8+
Discourse::Application.routes.draw { mount ::MyPluginModule::Engine, at: "my-plugin" }

lib/my_plugin_module/engine.rb

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
module ::MyPluginModule
4+
class Engine < ::Rails::Engine
5+
engine_name PLUGIN_NAME
6+
isolate_namespace MyPluginModule
7+
config.autoload_paths << File.join(config.root, "lib")
8+
end
9+
end

plugin.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,12 @@
99

1010
enabled_site_setting :plugin_name_enabled
1111

12-
after_initialize {}
12+
module ::MyPluginModule
13+
PLUGIN_NAME = "discourse-plugin-name"
14+
end
15+
16+
require_relative "lib/my_plugin_module/engine"
17+
18+
after_initialize do
19+
# Code which should run after Rails has finished booting
20+
end

0 commit comments

Comments
 (0)