Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with rerun 'rails generate administrate:install' #1003

Closed
leunis opened this issue Oct 14, 2017 · 5 comments
Closed

problem with rerun 'rails generate administrate:install' #1003

leunis opened this issue Oct 14, 2017 · 5 comments

Comments

@leunis
Copy link

leunis commented Oct 14, 2017

Hi,
When I rerun rails generate administrate:install on an existing project with extra models that I want to make available via administrate, it does not create new controllers and views.

How can I solve this

@nickcharlton
Copy link
Member

Hi @leunis!

So, to clarify, you've:

  1. Run rails g administrate:install and built dashboards based on new models.
  2. Added new models
  3. Rerun rails g administrate:install, and expect to see these new models have dashboards?

I suspect you're seeing administrate skip because it's already been run. Usually, you'd run the administrate:dashboard generator to achieve this instead.

Two potential things we could do:

  1. Change install so that it reruns regardless (which would potentially overwrite any adjustments you'd made to the existing files).
  2. Hint that instead you should be running the dashboard generator.

What do you think?

@stefanluptak
Copy link

@nickcharlton Then I would say that there's a mistake in the README.md file. Fixing it should be enough I guess. Right?

screen shot 2017-10-16 at 15 14 09

@nickcharlton
Copy link
Member

Ah hah! I suspect this is a regression from another change and we should restore the intended functionality.

@leunis
Copy link
Author

leunis commented Oct 16, 2017 via email

nickcharlton added a commit that referenced this issue Oct 29, 2017
As mentioned in #1003, rerunning the install generator doesn't actually
work as you'd expect. This removes that suggestion to avoid confusion.
@nickcharlton
Copy link
Member

I wasn't happy enough with what I'd understood with this issue, so I took some time to delve in and remind myself how the generators work.

The routes generator is really what's at play here, but the way it works isn't very smart. Inside administrate:install, administrate:routes is called when there's no existing resources in the admin namespace and then creates them. administrate:dashboard is called based on the admin resources. This explains why when you rerun install nothing appears to happen (as routes is never called, no new resources appear for dashboard to be run.

The bit where routes isn't very smart, is where it only inserts the routes again after being called. We're protecting against this because of that. I think it should be inserting into the existing namespace :admin block and there's #720 which is looking into this.

I've opened #1018 to remove the line from the documentation so it'll help others and opened #1019 so that we can look at an install generator that can be rerun as originally intended.

Finally, I'm going to close this one as a half-solution is the documentation fix and the real solution can be tracked elsewhere.

nickcharlton added a commit that referenced this issue Oct 29, 2017
As mentioned in #1003, rerunning the install generator doesn't actually
work as you'd expect. This removes that suggestion to avoid confusion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants