大家好,定義自定義動作控制器亙古不變的似乎工作的Rails管理
我有軌在我的項目實施現在有幾件事,我現在被困在
我想管理一個鏈接(標記爲發佈者)在列表視圖我的用戶控制器在rails管理員作爲ajax鏈接使用remote => true在rails中完成後,在那裏寫入關聯的jscode和html代碼
對上述自定義操作「mark_as_publisher」我定義的配置設置這樣
內配置/ 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
現在查看相同的定義在應用程序/視圖/ rails_admin /主/ 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"
是否有任何身體有什麼我失蹤