Newbie note: you must run the generator in the Discourse source directory (that’s /src if you use Docker). Otherwise you’ll just get confusing error/help messages about how the parameters are incorrect for rails new.
There seems to be a mismatch between the plugin generator and this post. Specifically, the Beginner’s Guide suggests to create the javascript initializer with the following directory and naming structure:
plugins/basic-plugin/assets/javascripts/discourse/initializers/alert.js.es6
However, the plugin creates the javascript initializer at
plugins/discourse-racoon/assets/javascripts/initializers/discourse-racoon.es6
Personally, I was having issues with the javascript loading after using this plugin until I changed the directory and naming structure to match the Beginner’s guide. Should the package be updated?
Yes would be better indeed.
Yes I had to rename the JavaScript extensions but the structure worked for me.
Cant help you, you give me no context. What did you type? where did you type it? clean or exisisting state?
I followed this tutorial https://meta.discourse.org/t/beginners-guide-to-creating-discourse-plugins-part-1/30515. Just installed and worked so guess its clean.
I typed:
bundle exec rails g plugin cidian
EDIT: Capitalization matters in ruby. The name of the plugin created by this generator gets to be a ruby class so that’s why a lower case argument supplied to this generator will lead to a broken plugin.
No it’s not clean as you have followed this tutorial to create a plugin, and the error is likely in what you typed while following the tutorial.
The error is very clear to me: mount ::cidian::Engine, at: "/cidian" is invalid. You should fix this in your code.
First of all: I dont know ruby (yet) as I will start from the front end.
this code was produced by this plugin generator. so its not my fault. Its the generators fault. I typed nothing while following the tutorial. I just followed the development environment setup guide for ubuntu. Before running the generator the local discourse instance worked fine.
https://github.com/discourse/discourse/blob/master/lib/generators/plugin/templates/plugin.rb.erb
to be very clear: I am just at the first page of this tutorial. specifically the part that links to this plugin generator.
これに大規模なアップデートを行いました。
今後も続きます:特定のジェネレーター(例えば、コントローラーを1つ追加する機能)や管理用プラグインなど。
おぉ!差分を見ると、プラグイン作成にあまり詳しくない人にもすごく良く見えるね。試してみるのが待ち遠しい(でも、月曜日にオフィスに着くまで待つかも
)
こんにちは、@j.jaffeux さん。試してみました(最初は失敗しましたが、再度 git pull を実行し、その後さらにいくつかのプラグインを作成しました)。すると、以下のエラーが発生しました。
/home/pfaffman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/mapper.rb:314:in `block (2 levels) in check_controller_and_action': 'one_two/one-two' is not a supported controller name. This can lead to potential routing problems. See http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use (ArgumentError)
とても残念です。このエラーで動作しなくなったプラグインに、実行する前に多くのコードを追加してしまったからです。どのように修正すればよいでしょうか?そのガイドや StackOverflow で見つけた情報では解決できませんでした。
よろしくお願いします。
ああ、そうです。私はこの他の問題に遭遇してしまい、まだ修正できていません。
controllers/one_two/one_two_controller.rb 应该是正确的,不过由于您没有提供所有数据,我也不太确定。
見つけたようです!犯人は config/routes.rb にいました。以下のように変更しました。
get "/" => "three-four#index", constraints: ThreeFourConstraint.new
を
get “/” => “three_four#index”, constraints: ThreeFourConstraint.new
に変更したところ、少なくとも私の素朴な目にはすべて問題なさそうです。
これについてどのように進めればよいでしょうか?
新しい Debian 環境(Windows サブシステム)でこれを使おうとしています。
Discourse は動作して実行されていますが、
rails g plugin --help
を実行すると、
/var/lib/gems/2.5.0/gems/railties-6.0.0/lib/rails/app_loader.rb:53: warning: Insecure world writable dir /home/jose/.rbenv/shims in PATH, mode 040777
Could not find actionview_precompiler-0.2.1 in any of the sources
Run `bundle install` to install missing gems.
というエラーが表示されます。
bundle install を実行しても何も起こりません(新規環境)し、precompiler は gem のリストに含まれています。
何か良いアイデアはありますか?
Discourse サーバーは Docker コンテナ内で実行されていますか?もしそうなら、コンテナの内部で bundle install を実行する必要があります。
いいえ、そうではないと思います。これは開発用インスタンスであり、直接 git clone したものです。
これは最初から完璧に動作しました。
ありがとうございます。
この Rails ジェネレーターを実行して、新しいプラグインの基本的な構造を作成し、Git にアップロードし、YML に追加してアプリを再構築したところ、最初から問題なくインストールされました。
プラグインタブにアクセスすると、最初から有効化/無効化設定が備わった状態で表示されました。![]()
使いやすく便利なこのジェネレーターを提供してくださった @j.jaffeux さんに心から感謝します。
私が行った唯一の変更は、含まれていた .git ディレクトリを rm -rf で削除し、Git を再初期化して自分のアカウントにプッシュできるようにしたことです。ただし、これはおそらく私が git にあまり詳しくなく、意図した通りに動作させるために git things にハンマーで叩きつけていることが多いためでしょう。
完璧なジェネレーターです。改めてありがとうございます、@j.jaffeux
お役に立てて嬉しいです。正直に言うと、まだ正しく動作していないことがたくさんあるので、それに時間を割くべきですね。
