DEV: Add rails engine and file paths to skeleton (#29)

This commit is contained in:
David Taylor 2023-02-24 13:00:01 +00:00 committed by GitHub
parent f19d9a8aa6
commit 8421cf6d72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 1 deletions

View 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
View 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" }

View 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

View File

@ -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