activeadmin / inherited_resources

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

resource_url not correct for new records?

datenimperator opened this issue · comments

I used to have a shared form partial using simple_form for both :create and :update actions. It usually looks like this:

= simple_form_for resource do |f|
  # form inputs

When using this with a namespaced controller Admin::UsersController for the class Users, simple_form needs information about that namespace. Without inherited_resources I usually write simple_form_for [:admin, @user] but I figured I could get rid of that for my app which uses two different namespaces.

I found that I could get around simple_form not being able to detect the namespace by providing an url:

= simple_form_for resource, url:resource_url do |f|
  # form inputs

This works for updates but not for creating new records. Even for new records it tries to give me the :show URL, which fails with an ActionController::RoutingError when rendering the form. Is this an error or am I holding it wrong? :-)

Please use the mailing list or StackOverflow for questions/help, where a wider community will be able to help you. We reserve the issues tracker for issues only.