3

I have this in my routes file (at the top):

mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'

Rails_admin was working, yet now rake routes shows:

Routes for RailsAdmin::Engine:
    dashboard GET         /                                      rails_admin/main#dashboard
        index GET|POST    /:model_name(.:format)                 rails_admin/main#index
          new GET|POST    /:model_name/new(.:format)             rails_admin/main#new
       export GET|POST    /:model_name/export(.:format)          rails_admin/main#export
  bulk_delete POST|DELETE /:model_name/bulk_delete(.:format)     rails_admin/main#bulk_delete
history_index GET         /:model_name/history(.:format)         rails_admin/main#history_index
  bulk_action POST        /:model_name/bulk_action(.:format)     rails_admin/main#bulk_action
         show GET         /:model_name/:id(.:format)             rails_admin/main#show
         edit GET|PUT     /:model_name/:id/edit(.:format)        rails_admin/main#edit
       delete GET|DELETE  /:model_name/:id/delete(.:format)      rails_admin/main#delete
 history_show GET         /:model_name/:id/history(.:format)     rails_admin/main#history_show
  show_in_app GET         /:model_name/:id/show_in_app(.:format) rails_admin/main#show_in_app

The only thing I've done since restarting the server is add a custom action, which I've since removed, yet still receiving this very strange error.

Any ideas?

Damien Roche
  • 13,189
  • 18
  • 68
  • 96

2 Answers2

1

Well, it turned out to be a bit weird I created a new view and in the view did self.methods got a big list with helpers, then saw rails_admin, I did as you have

mount RailsAdmin::Engine => '/', :as => 'rails_admin'

then checked rails_admin.methods and found rails_admin.edit_path, which did work as in routes:

Routes for RailsAdmin::Engine:
      dashboard GET    /                                      
    ...
      edit GET|PUT     /:model_name/:id/edit(.:format)

So in my case rails_admin.edit_path(model_name: 'order', id: 12) worked!

Answer: its rails_admin.*_path

where * is show, edit, delete, new, index etc.

Be sure to do in routes.rb: the as: 'rails_admin'

mount RailsAdmin::Engine => '/', as: 'rails_admin'
merof
  • 121
  • 7
0

The error is not as strange as you think. If the original route to the RailsAdmin engine was /admin, there is almost surely some code somewhere requests a path using that syntax. Something like admin_xxx_xxx_path or admin_xxx_xxx_url. The Rails url helpers would try to interpret this as /admin/xxx/xxx and the routing error would return with 'rails_admin no route matches '/admin'.

spinriko
  • 46
  • 6