1

Routing Error ! uninitialized constant AdminController

This appears to me when trying to go to

localhost:3000/admin

I have been searching a lot , but still stuck!

Rails 4.2.4

Ruby 2.2.3

Activeadmin 1.0.0 pre2

My Gem file :5dPDVf http://ideone.com/5dPDVf

My routes.rb File : dF6EFThttp://ideone.com/dF6EFT

Phiter
  • 12,987
  • 14
  • 45
  • 77
  • Welcome to StackOverflow. Be good if you post the class definition and location of AdminController, it may be a pluralisation issue: e.g. https://stackoverflow.com/questions/15845491/routing-error-uninitialized-constant – Tim Feb 21 '16 at 18:40
  • Thnx 4 your reply 1-/myapp/app/admin/dashbored.rb->http://ideone.com/T3p6Za 2-/myapp/config/intializers/active_admin.rb->http://ideone.com/0pfHHe 3-/myapp/config/environment/production.rb->http://ideone.com/OQHCQC 4-/myapp/config/environment/development.rb->http://ideone.com/NY1qda 5-/myapp/config/environment/test.rb->http://ideone.com/fKnRjm 6-/myapp/config/application.rb->http://ideone.com/zS7sSP 7-/myapp/app/controllers/application_controller.rb-> http://ideone.com/6DfMEU 8-/myapp/app/models/admin_user.rb->http://ideone.com/LCLOHD 9-/myapp/app/admin/admin_user.rb->http://ideone.com/qpCgtL – Karim Abd Elhameed Mohamed Feb 21 '16 at 19:18
  • Please Note that I am a very new Rails developer , So if anything isn't clear for you , it's my fault and your help is appreciable for me . Thanks Tim – Karim Abd Elhameed Mohamed Feb 21 '16 at 19:20
  • No problem Karim, I was just going through a review queue , I see someone had gotten to you. Good luck. – Tim Feb 21 '16 at 19:50
  • Not yet , Still have problem and stuck :/ – Karim Abd Elhameed Mohamed Feb 21 '16 at 20:04

2 Answers2

0

Did you run rails generate active_admin:install ?

Eduardo
  • 76
  • 1
  • 9
0

Looks like you need to create an AdminsController class like this:

in app/controllers/admins_controller.rb

class AdminsController < ApplicationController
  def index      
  end 
end

You might want to read Action Controller Overview

You might have it defined as AdminsController (plural) so you might need to adjust your routes to this instead of creating an AdminsController class.

The controller name should be plural (this is a naming convention in Rails).

routes.rb

resources :admins

You'll also need a view file inapp/views/admins/ called index.html.erb

and then visit http://localhost:3000/admins.

Andrew Hendrie
  • 5,455
  • 3
  • 37
  • 64
  • Thanks Andrew for replay , I have created admin_controller.rb but Is that anything to put instead of this dots (...) between declaration for call and it's end ?? - When I create it and erase these dots I opened by routes.rb and add resources :admins It still the same and I also try resources :admin (Singular) it also not working ! – Karim Abd Elhameed Mohamed Feb 21 '16 at 19:35
  • see edit about the controller name being plural - the ... can be replaced by actions like `def index end` (again - see edit in my answer also recommend reading the Action Controller Overview Rails Guide. – Andrew Hendrie Feb 21 '16 at 19:51
  • Now , I got something new -> Template is missing "Missing template admins/index, application/index with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :arb, :jbuilder]}. Searched in: * "/home/karim/myapp/app/views" * "/home/karim/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/devise-3.5.6/app/views" * "/home/karim/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-f7483e3b8fcd/app/views" * "/home/karim/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/kaminari-0.16.3/app/views" – Karim Abd Elhameed Mohamed Feb 21 '16 at 20:01
  • You need to create a view file: `app/views/admins/index.html.erb` – Andrew Hendrie Feb 21 '16 at 20:08
  • Umm,It works!but not as excepted Sir please,I have my app folders structure look like admin,assets,controllers,helpers,mailers,models,views I opened the views folder as u said,and create new folder admins/index.html.erb but , we I load localhost:3000/admins -> it appears blank page for me It is obviously because of this new page that I create and when running localhost:3000/admins/admin_users->it expect to show admins but it gives"The action 'show' could not be found for AdminsController".I am following some Udemy course tutorials and he didn't face this due to rails,activeadmin diff. versions – Karim Abd Elhameed Mohamed Feb 21 '16 at 20:34
  • you'll need to create a show action in your AdminsController and a view that corresponds with it. You can add HTML to the `index.html.erb` file if you want to display something on that page. – Andrew Hendrie Feb 21 '16 at 20:38
  • Ummm Thanks for you Time – Karim Abd Elhameed Mohamed Feb 21 '16 at 20:49