2

皆さんこんにちは 、

私は自分のプロジェクトにレール管理者を実装しましたが、現在行き詰まっていることがいくつかあります

  1. リンクが必要です(パブリッシャーとしてマーク)レール管理者のユーザーコントローラーのリストビューでajaxリンクとしてリモート=> trueを使用して実行された後、レールで関連するjscodeとhtmlコードを書き込みます

  2. 上記のカスタム アクション「mark_as_publisher」に対して、次のような構成設定を定義します

    config/rails_admin.rb

     config.actions do 
    
            # root actions
          dashboard                     # mandatory
          # collection actions 
          index                         # mandatory
          new
          export
          history_index
          bulk_delete
          # member actions
          show
          edit
          delete
          history_show
          show_in_app
          member :mark_as_publisher
     end
    

    カスタムアクションの定義は次のようになります

    require "rails_admin_mark_as_publisher/engine"
    
    module RailsAdminMarkAsPublisher
    end
    
    require 'rails_admin/config/actions'
    
    module RailsAdmin
      module Config
        module Actions
          class MarkAsPublihser < Base
            RailsAdmin::Config::Actions.register(self)
    
            register_instance_option :collection do
              true
            end
    
            register_instance_option :http_methods do
              [:get,:post]
            end
    
            register_instance_option :route_fragment do
              'mark_as_publisher'
            end 
    
            register_instance_option :controller do
              Proc.new do
                binding.pry
                if request.get?
                  respond_to do |format|
                    format.html { render @action.template_name} 
                  end
                elsif request.post?
                  redirect_path = nil
                  if @object.update_attributes(:manager => true)
                    flash[:success] = t("admin.flash.successful", :name => @model_config.label, :action => t("admin.actions.mark_as_publisher.done"))
                    redirect_path = index_path
                  else
                    flash[:error] = t("admin.flash.error", :name => @model_config.label, :action => t("admin.actions.mark_as_publisher.done"))
                    redirect_path = back_or_index
                  end
                end  
              end
            end  
          end
        end
      end
    end
    

app/view/rails_admin/main/mark_as_publisher.erbの同じ定義のビューは次の ようになります

<%=  rails_admin_form_for @object, :url => mark_as_publisher_path(:model_name => @abstract_model.to_param, :id => @object.id), :as => @abstract_model.param_key,:method => :post ,:html => { :class => "form-horizontal denser", :data => { :title => "Mark" } } do |form| %>
  <%= form.submit "save" %>
<%end%>

mark_as_publisher の get および post url は、上記のコントローラー定義によって取得され、上記のフォームを保存すると、というエラーが発生します。

could not find routes for '/user/5/mark_as_publisher' :method => "post"

どんな体でも、私が欠けているもののアイデアを持っていますか

4

1 に答える 1