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

uninitialized constant Administrate::Generators::InstallGenerator::DashboardManifest #431

Closed
frabrunelle opened this issue Jan 22, 2016 · 16 comments

Comments

@frabrunelle
Copy link

Hi 😃

When I run the installer for Administrate, I get the following error:

rails generate administrate:install
Running via Spring preloader in process 33128
      create  app/controllers/admin/application_controller.rb
       route  namespace :admin do
    DashboardManifest::DASHBOARDS.each do |dashboard_resource|
      resources dashboard_resource
    end

    root controller: DashboardManifest::ROOT_DASHBOARD, action: :index
  end
      create  app/dashboards/dashboard_manifest.rb
/usr/local/lib/ruby/gems/2.3.0/gems/administrate-0.1.3/lib/generators/administrate/install/install_generator.rb:44:in `manifest': uninitialized constant Administrate::Generators::InstallGenerator::DashboardManifest (NameError)
    from /usr/local/lib/ruby/gems/2.3.0/gems/administrate-0.1.3/lib/generators/administrate/install/install_generator.rb:36:in `dashboard_resources'
    from /usr/local/lib/ruby/gems/2.3.0/gems/administrate-0.1.3/lib/generators/administrate/install/install_generator.rb:32:in `singular_dashboard_resources'
    from /usr/local/lib/ruby/gems/2.3.0/gems/administrate-0.1.3/lib/generators/administrate/install/install_generator.rb:24:in `run_dashboard_generators'
    from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
    from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
    from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
    from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
    from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
    from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /usr/local/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/generators.rb:157:in `invoke'
    from /usr/local/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/commands/generate.rb:13:in `<top (required)>'
    from /usr/local/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:123:in `require_command!'
    from /usr/local/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:130:in `generate_or_destroy'
    from /usr/local/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:50:in `generate'
    from /usr/local/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /usr/local/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
    from /Users/frabrunelle/administrate/bin/rails:9:in `<top (required)>'
    from /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from -e:1:in `<main>'

Is anyone else getting this error? I get this error even on a totally new Rails application, so it should be pretty easy to reproduce.

@Xosmond
Copy link

Xosmond commented Jan 22, 2016

I was getting this for hours :

´´´
The Gemfile's dependencies are satisfied
/Users/EGN/Developer/Ruby/seguridad/config/routes.rb:3:in block (2 levels) in <top (required)>': uninitialized constant DashboardManifest (NameError) from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/actionpack-4.2.5/lib/action_dispatch/routing/mapper.rb:882:inblock in namespace'
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/actionpack-4.2.5/lib/action_dispatch/routing/mapper.rb:817:in scope' from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/actionpack-4.2.5/lib/action_dispatch/routing/mapper.rb:882:innamespace'
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/actionpack-4.2.5/lib/action_dispatch/routing/mapper.rb:1456:in namespace' from /Users/EGN/Developer/Ruby/seguridad/config/routes.rb:2:inblock in <top (required)>'
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/actionpack-4.2.5/lib/action_dispatch/routing/route_set.rb:434:in instance_exec' from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/actionpack-4.2.5/lib/action_dispatch/routing/route_set.rb:434:ineval_block'
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/actionpack-4.2.5/lib/action_dispatch/routing/route_set.rb:412:in draw' from /Users/EGN/Developer/Ruby/seguridad/config/routes.rb:1:in<top (required)>'
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:40:in block in load_paths' from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:40:ineach'
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:40:in load_paths' from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:16:inreload!'
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:26:in block in updater' from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/file_update_checker.rb:75:inexecute'
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:7:in execute' from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/application/finisher.rb:81:inblock (2 levels) in module:Finisher'
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:446:in instance_exec' from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:446:inblock in make_lambda'
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:192:in block in simple' from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:504:inblock in call'
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:504:in each' from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:504:incall'
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:92:in __run_callbacks__' from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:778:in_run_prepare_callbacks'
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:81:in run_callbacks' from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/reloader.rb:83:inprepare!'
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/reloader.rb:55:in prepare!' from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.6.2/lib/spring/application.rb:153:inserve'
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.6.2/lib/spring/application.rb:131:in block in run' from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.6.2/lib/spring/application.rb:125:inloop'
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.6.2/lib/spring/application.rb:125:in run' from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.6.2/lib/spring/application/boot.rb:18:in<top (required)>'
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from -e:1:in `

'
´´´

But after installing for 10 times now its working, the reason? i don't know u.u

@MincePie
Copy link

Hi, I'm having the same problem. Did you figure this out?
When I do: rails generate administrate:install

I get this error:
`block (2 levels) in <top (required)>': uninitialized constant DashboardManifest (NameError)

Reading some of the blogs about this, it seems that it might be related to spring gem or HABTM relationships which are defined incorrectly. I'm not sure if there is a suggested solution. Have you figured out how to fix this?

Thanks

@Xosmond
Copy link

Xosmond commented Jan 23, 2016

Well when you "rails generate administrate:install" the routes appear in the config/routes.rb file, and those line generate the error. So, i "rails generate administrate:install" and then removed that lines from config/routes.rb file like 10 times, maybe is what you are saying (the spring gem) or something more complicated.

@MincePie
Copy link

But don't you need the routes for the gem to work? It put these lines in my routes file:

namespace :admin do
DashboardManifest::DASHBOARDS.each do |dashboard_resource|
resources dashboard_resource
end

root controller: DashboardManifest::ROOT_DASHBOARD, action: :index

end

Are you saying the solution is to delete all of this?

@Xosmond
Copy link

Xosmond commented Jan 23, 2016

Im saying that you should delete them and try to install administrate again(when you install it again the routes will appear again on the routes file), then test if it works. I did many times.

@QuintinAdam
Copy link

I was also getting this error. i deleted the lines it added in my routes then ran spring stop and the generator again and this time it worked.

@MincePie
Copy link

thanks Quintin - that worked for me too

@Xosmond
Copy link

Xosmond commented Jan 23, 2016

Yes that makes sense, spring always causing problems

@s2t2
Copy link

s2t2 commented Jan 24, 2016

DISABLE_SPRING=1 rails generate administrate:install works. thanks.

@frabrunelle
Copy link
Author

Works for me too! Thanks 😃

@joshforeman
Copy link

Worked for me too. Thank you.

@robertofarrell
Copy link

I ran into this issue as well. Turns out I had my rails server running when I tried to run the install command. Removed the routes, shutdown the server, and ran it again without issue.

@ddsbrddn
Copy link

ddsbrddn commented Feb 1, 2016

DISABLE_SPRING=1 rails generate administrate:install works fine.

@d1rtyvans
Copy link

@MincePie 👍 deleting the routes and reinstalling worked for me

c-lliope added a commit that referenced this issue Feb 13, 2016
Problem:

When users run the `administrate:install` generator multiple times,
the generated routes from the first install prevent following installs
from working correctly.

In order to get subsequent installs to run correctly,
users must delete the already-generated routes
and run the installer again from scratch.

This has thrown many people off,
and there is discussion of the issue in:

- #431
- #448

Solution:

We should change the generated routes
so they don't rely on a `DashboardManifest` being defined.

I'm not sure what the best way to do that would be,
but here are a couple options

Defining routes directly

This option would look something like:

```ruby
namespace :admin do
  resources :customers
  resources :orders
  resources :products
  resources :line_items

  root to: "customers#index"
end
```

That would fix the error that people are getting
when they run `rails generate administrate:install` multiple times,
but it would be more work to update the routes if they change over time.

If we went this route,
I'd want to look into getting rid of the `DashboardManifest` completely.
It would be cumbersome to update the list of dashboards
in multiple locations,
and we could potentially look at the routes that the user's defined to
determine which sidebar links to display.

Wrap routes in a conditional

Alternatively we could keep it how it is,
but wrap the block in a conditional - that might look like:

```ruby
if defined?(DashboardManifest)
  namespace :admin do
    DashboardManifest::DASHBOARDS.each do |dashboard_resource|
      resources dashboard_resource
    end

    root controller: DashboardManifest::ROOT_DASHBOARD, action: :index
  end
end
```

Define routes through the engine

This is the approach that RailsAdmin and Active Admin take.
It would look like:

```ruby
Rails.application.routes.draw do
  mount :administrate
end
```

This approach is rather opaque,
and it makes it harder for the developer to see what's going on.
Behind the scenes we could use any approach we wanted to make sure
the `DashboardManifest` is defined when we need it.

Thoughts?

What's the best approach to take here?
- Are we comfortable mounting an engine
  and abstracting away the complexity?
- Is it worth it to introduce a conditional check
  into peoples' routes file?
- Would we prefer to get rid of the `DashboardManifest` altogether,
  and use the user's routes to fill that role instead?
@c-lliope
Copy link
Contributor

I created issue #464 to discuss ways to get around the routes error.

@frabrunelle, @Xosmond, @MincePie, @QuintinAdam, @s2t2 and others, please join the discussion there!

@c-lliope
Copy link
Contributor

Fixed by #464, which will go out in 0.2.0.

maripiyoko added a commit to maripiyoko/administrate-demo that referenced this issue Feb 21, 2016
rails generate administrate:install

現在 springが動いている状態で上記コマンドを実行するとエラーが発生して実行が途中で止まってしまう。

ref: thoughtbot/administrate#431
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

10 participants