ruby on rails 4 - Rails_admin custom action specify template name -


my app rails 4.1 rails_admin 0.8.1. want create custom action shows articles belong logged in user. if using regular rails scaffolding create new action in articles controller , tell use index view.

i registered action in rails_admin.rb shows up. how specify template_name in ra? keep getting missing template rails_admin/main/myarticles ... when browse http://localhost:3000/admin/article/myarticles

class article   include mongoid::document   field :title, type: string   belongs_to :user   ...   def my_articles current_user     article.where(user: current_user)   end end  class myarticles < railsadmin::config::actions::base   railsadmin::config::actions.register(self)   register_instance_option :collection     true   end   register_instance_option :visible?     authorized?   end   register_instance_option :only     article   end   register_instance_option :template_name     :index  # not work   end   register_instance_option :controller     proc       @objects = article.my_articles(current_user)     end   end end 

finally figured out.

  class myarticles < collectionaction     railsadmin::config::actions.register(self)     ...     register_instance_option :controller       proc         @objects = article.where(user: current_user)         render :index       end     end   end 

you push filter logic model or object if want to.


Comments