Note that there are some explanatory texts on larger screens.

plurals
  1. PODefine Controller for the custom action doesnot seem to work Rails Admin
    primarykey
    data
    text
    <p>HI Everyone ,</p> <p>I have rails admin implemented in my project Now there are couple of thing that I currently stuck at</p> <ol> <li><p>I want a link (Mark as Publisher) In the list View of my user Controller in the rails admin as ajax link something that is done using <strong>remote => true</strong> in rails after that where the write the associated jscode and html code for it</p></li> <li><p>for the above custom action "<strong>mark_as_publisher</strong>" I define the configuration setting like this</p> <p>Inside <strong>config/rails_admin.rb</strong></p> <pre><code> 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 </code></pre> <p>Now The Definition of the custom action look like this</p> <pre><code>require "rails_admin_mark_as_publisher/engine" module RailsAdminMarkAsPublisher end require 'rails_admin/config/actions' module RailsAdmin module Config module Actions class MarkAsPublihser &lt; 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 =&gt; true) flash[:success] = t("admin.flash.successful", :name =&gt; @model_config.label, :action =&gt; t("admin.actions.mark_as_publisher.done")) redirect_path = index_path else flash[:error] = t("admin.flash.error", :name =&gt; @model_config.label, :action =&gt; t("admin.actions.mark_as_publisher.done")) redirect_path = back_or_index end end end end end end end end </code></pre></li> </ol> <p>Now the View for the same define in <strong>app/view/rails_admin/main/mark_as_publisher.erb</strong> look like this</p> <pre><code>&lt;%= rails_admin_form_for @object, :url =&gt; mark_as_publisher_path(:model_name =&gt; @abstract_model.to_param, :id =&gt; @object.id), :as =&gt; @abstract_model.param_key,:method =&gt; :post ,:html =&gt; { :class =&gt; "form-horizontal denser", :data =&gt; { :title =&gt; "Mark" } } do |form| %&gt; &lt;%= form.submit "save" %&gt; &lt;%end%&gt; </code></pre> <p>The get and post url for mark_as_publisher does come under by controller define above and saving the above form result in error called</p> <p><code>could not find routes for '/user/5/mark_as_publisher' :method =&gt; "post"</code></p> <p>Does Any body has an idea of what I'm missing</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload