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

Done #1117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Done #1117

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/controllers/admin/stats_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Admin::StatsController < ApplicationController
# the classname must be prefixed by Admin because it is now located in the Admin dir and not at the Controllers root dir
def index
@post_count = Post.count
@authors_count = Author.count
@last_post = Post.last
end
end
8 changes: 0 additions & 8 deletions app/controllers/stats_controller.rb

This file was deleted.

File renamed without changes.
16 changes: 15 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,21 @@

resources :posts, only: %i[index show new create edit update]

get '/admin/stats', to: 'stats#index'
# original
# get '/admin/stats', to: 'stats#index'

# scope version
# scope allows for grouping of routes under a specified URL path. We have further grouped the controllers and views together under Admin, so we need to declare that module
# scope '/admin', module: 'admin' do
# resources :stats, only: [:index]
# end

# namespace version
# namespacing can be used when want want to use the same name for both the module and the URL prefix
# simplified declaration of routes, assumes path prefix and module name match
namespace :admin do
resources :stats, only: [:index]
end

root 'posts#index'
end
49 changes: 49 additions & 0 deletions log/development.log
Original file line number Diff line number Diff line change
Expand Up @@ -4470,3 +4470,52 @@ ActionController::RoutingError (No route matches [GET] "/stats"):
Rendered /Users/scottcreynolds/.rvm/gems/ruby-2.1.2/gems/web-console-2.2.1/lib/web_console/templates/main.js.erb within layouts/javascript (0.2ms)
Rendered /Users/scottcreynolds/.rvm/gems/ruby-2.1.2/gems/web-console-2.2.1/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.4ms)
Rendered /Users/scottcreynolds/.rvm/gems/ruby-2.1.2/gems/web-console-2.2.1/lib/web_console/templates/index.html.erb (34.6ms)
DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement. (called from <top (required)> at /mnt/c/Users/Kristen/dev/flatiron/labs/namespaced-routes-reading-v-000/config/environment.rb:5)
DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement. (called from <top (required)> at /mnt/c/Users/Kristen/dev/flatiron/labs/namespaced-routes-reading-v-000/config/environment.rb:5)
DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement. (called from <top (required)> at /mnt/c/Users/Kristen/dev/flatiron/labs/namespaced-routes-reading-v-000/config/environment.rb:5)
DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement. (called from <top (required)> at /mnt/c/Users/Kristen/dev/flatiron/labs/namespaced-routes-reading-v-000/config/environment.rb:5)
DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement. (called from <top (required)> at /mnt/c/Users/Kristen/dev/flatiron/labs/namespaced-routes-reading-v-000/config/environment.rb:5)
DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement. (called from <top (required)> at /mnt/c/Users/Kristen/dev/flatiron/labs/namespaced-routes-reading-v-000/config/environment.rb:5)
DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement. (called from <top (required)> at /mnt/c/Users/Kristen/dev/flatiron/labs/namespaced-routes-reading-v-000/config/environment.rb:5)
DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement. (called from <top (required)> at /mnt/c/Users/Kristen/dev/flatiron/labs/namespaced-routes-reading-v-000/config/environment.rb:5)
Started GET "/" for 127.0.0.1 at 2021-04-23 12:47:01 -0500
ActiveRecord::SchemaMigration Load (1.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by PostsController#index as HTML
Rendering posts/index.html.erb within layouts/application
Post Load (1.9ms) SELECT "posts".* FROM "posts"
Author Load (1.9ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
Author Load (2.1ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" = ? LIMIT ? [["id", 2], ["LIMIT", 1]]
Author Load (2.1ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" = ? LIMIT ? [["id", 3], ["LIMIT", 1]]
Rendered posts/index.html.erb within layouts/application (270.9ms)
Completed 200 OK in 2533ms (Views: 2366.7ms | ActiveRecord: 22.3ms)


Started GET "/admin/stats" for 127.0.0.1 at 2021-04-23 12:47:11 -0500
Processing by Admin::StatsController#index as HTML
 (1.7ms) SELECT COUNT(*) FROM "posts"
 (1.7ms) SELECT COUNT(*) FROM "authors"
Post Load (2.1ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" DESC LIMIT ? [["LIMIT", 1]]
Rendering admin/stats/index.html.erb within layouts/application
Rendered admin/stats/index.html.erb within layouts/application (0.8ms)
Completed 200 OK in 466ms (Views: 374.8ms | ActiveRecord: 5.6ms)


Started GET "/admin/stats" for 127.0.0.1 at 2021-04-23 12:50:29 -0500
Processing by Admin::StatsController#index as HTML
 (1.4ms) SELECT COUNT(*) FROM "posts"
 (1.5ms) SELECT COUNT(*) FROM "authors"
Post Load (2.0ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" DESC LIMIT ? [["LIMIT", 1]]
Rendering admin/stats/index.html.erb within layouts/application
Rendered admin/stats/index.html.erb within layouts/application (1.7ms)
Completed 200 OK in 643ms (Views: 416.9ms | ActiveRecord: 17.2ms)


Started GET "/assets/authors.self-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css?body=1" for 127.0.0.1 at 2021-04-23 12:50:30 -0500
Started GET "/assets/application.self-e80e8f2318043e8af94dddc2adad5a4f09739a8ebb323b3ab31cd71d45fd9113.css?body=1" for 127.0.0.1 at 2021-04-23 12:50:30 -0500
Started GET "/assets/jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1" for 127.0.0.1 at 2021-04-23 12:50:30 -0500
Started GET "/assets/jquery_ujs.self-784a997f6726036b1993eb2217c9cb558e1cbb801c6da88105588c56f13b466a.js?body=1" for 127.0.0.1 at 2021-04-23 12:50:31 -0500
Started GET "/assets/turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1" for 127.0.0.1 at 2021-04-23 12:50:31 -0500
Started GET "/assets/authors.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for 127.0.0.1 at 2021-04-23 12:50:31 -0500
Started GET "/assets/application.self-3b8dabdc891efe46b9a144b400ad69e37d7e5876bdc39dee783419a69d7ca819.js?body=1" for 127.0.0.1 at 2021-04-23 12:50:31 -0500
DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement. (called from <top (required)> at /mnt/c/Users/Kristen/dev/flatiron/labs/namespaced-routes-reading-v-000/config/environment.rb:5)
DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement. (called from <top (required)> at /mnt/c/Users/Kristen/dev/flatiron/labs/namespaced-routes-reading-v-000/config/environment.rb:5)
1 change: 0 additions & 1 deletion tmp/pids/server.pid

This file was deleted.