Skip to content

Commit

Permalink
使用傳統開發方式加入 admin/pages#dashboard 頁面及相關 JS
Browse files Browse the repository at this point in the history
  • Loading branch information
hungmi committed Sep 22, 2021
1 parent 655b227 commit 85d9fe3
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/assets/config/manifest.js
@@ -1,3 +1,4 @@
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link application.js
//= link admin/application.js
5 changes: 5 additions & 0 deletions app/assets/javascripts/admin/application.js
@@ -0,0 +1,5 @@
//= require admin/pages-dashboard

window.addEventListener("load", function(event) {
console.log('hello! from admin/application')
})
3 changes: 3 additions & 0 deletions app/assets/javascripts/admin/pages-dashboard.js
@@ -0,0 +1,3 @@
window.addEventListener("load", function(event) {
console.log('hello! from admin/pages-dashboard.js')
})
3 changes: 3 additions & 0 deletions app/assets/stylesheets/admin/pages.scss
@@ -0,0 +1,3 @@
// Place all the styles related to the admin/pages controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
6 changes: 6 additions & 0 deletions app/controllers/admin/pages_controller.rb
@@ -0,0 +1,6 @@
class Admin::PagesController < ApplicationController
layout 'admin'

def dashboard
end
end
2 changes: 2 additions & 0 deletions app/views/admin/pages/dashboard.html.erb
@@ -0,0 +1,2 @@
<h1>Admin::Pages#dashboard</h1>
<p>Find me in app/views/admin/pages/dashboard.html.erb</p>
16 changes: 16 additions & 0 deletions app/views/layouts/admin.html.erb
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>Admin</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_include_tag 'admin/application' %>
</head>

<body>
<%= yield %>
</body>
</html>
3 changes: 3 additions & 0 deletions config/routes.rb
@@ -1,4 +1,7 @@
Rails.application.routes.draw do
namespace :admin do
get 'pages/dashboard'
end
root 'pages#home'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end

0 comments on commit 85d9fe3

Please sign in to comment.