첫 번째 플러그인을 개발 중인데, 버튼을 누른 후 관리자 패널(플러그인의 일부)에 있는 텍스트 박스의 텍스트 콘텐츠를 가져오고 싶습니다. 그런 다음 Ruby에서 해당 콘텐츠로 몇 가지 작업을 처리하려고 합니다. Ember 프론트엔드에서 Ruby 백엔드로 데이터를 보내는 방법이 있을까요?
제 plugin.rb:
# name: Discourse Sample Plugin
# about: A simple plugin to play around with
# version: 1.0.0
# authors: NateDhaliwal
# url: https://google.com
enabled_site_setting :plugin_enabled
add_admin_route 'sample_page.title', 'sample-page'
Discourse::Application.routes.append do
get '/admin/plugins/sample-page' => 'admin/plugins#index', constraints: StaffConstraint.new
end
제 assets/javascripts/discourse/templates/admin/plugin-sample-plugin.hbs:
제 assets/javascripts/discourse/controllers/admin-plugins-sample-plugin.js.es6:
import Controller from "@ember/controller";
import { action } from "@ember/object";
export default class AdminPluginsSamplePlugin extends Controller {
@action
sendTextboxData() {
// How do I send the data?
}
}
만약 Ruby 백엔드로 데이터를 보내는 데 성공한다면, 데이터를 처리하는 로직은 어디에 두어야 할까요? plugin.rb에 두는 것이 맞나요? 아니면 다른 파일에 두어야 하나요?