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.
Acabei de fazer uma atualização massiva nisso.
Mais por vir: geradores específicos, ou seja, adicionar um controlador, por exemplo, e plugins de administração.
Uau! Parece ótimo na diff (para alguém que sabe muito pouco sobre como escrever plugins). Mal posso esperar para testar (mas provavelmente vou esperar até chegar ao escritório na segunda-feira
)
Ei, @j.jaffeux, acabei de testar (e fiz um git pull novamente e criei alguns plugins extras depois que falhou na primeira vez) e estou recebendo:
/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' não é um nome de controlador suportado. Isso pode levar a problemas de roteamento. Consulte http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use (ArgumentError)
Estou triste porque tenho um plugin que começou com isso e ao qual adicionei bastante código antes de executá-lo. Você pode me dizer como corrigir isso? O conteúdo daquele guia e o que encontrei no StackOverflow não me ajudam.
Obrigado.
Sim, encontrei esse outro problema e ainda não o corrigi.
Acho que deveria ser controllers/one_two/one_two_controller.rb, mas não tenho certeza, já que você não forneceu todos os dados.
Parece que encontrei! O culpado está em config/routes.rb. Eu mudei
get "/" => "three-four#index", constraints: ThreeFourConstraint.new
para
get “/” => “three_four#index”, constraints: ThreeFourConstraint.new
e tudo está bem, pelo menos aos meus olhos ingênuos.
Como devo proceder com isso?
Tentando usar isso no meu novo ambiente Debian do Windows Subsystem
Meu Discourse funciona e roda, mas quando tento executar
rails g plugin --help
recebo
/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.
Executar bundle install não faz nada (novo) e o precompiler está na lista de gems.
Alguma ideia?
Seu servidor Discourse está rodando em um contêiner Docker? Se sim, você precisa executar o bundle install dentro do contêiner.
Não, eu não acho que seja. É uma instância de desenvolvimento, então foi um clone direto do Git.
Isso funcionou perfeitamente OOTB.
Obrigado por isso.
Apenas executei este gerador do Rails e criei a estrutura básica para um novo plugin, fiz o upload para o git, adicionei ao yml, reconstruí o app e ele foi instalado perfeitamente OOTB.
Acessei a aba de plugins e lá estava ela, totalmente equipada com uma configuração OOTB de ativar/desativar. ![]()
Muito obrigado @j.jaffeux por este gerador fácil de usar e útil.
A única alteração que fiz foi executar rm -rf no diretório .git incluído e re-init o git para que eu pudesse enviá-lo para minha conta; mas isso provavelmente foi porque não sou muito habilidoso com git e frequentemente tenho que bater em coisas do git com um martelo para fazê-las funcionar como eu acho que deveriam.
Gerador impecável. Obrigado novamente @j.jaffeux
Fico feliz que tenha funcionado para você. Para ser honesto, deveria investir tempo nisso, pois há muitas coisas que não estão funcionando corretamente.
