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

관리자 구조 만들고 users 대시보드 추가 #2

Merged
merged 1 commit into from Aug 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -29,3 +29,4 @@
/yarn-error.log
yarn-debug.log*
.yarn-integrity
/.vscode
2 changes: 1 addition & 1 deletion app/assets/stylesheets/application.css
Expand Up @@ -14,4 +14,4 @@
*= require_self
*/

@import 'bulma/bulma';
@import 'semantic-ui/dist/semantic';
3 changes: 3 additions & 0 deletions app/assets/stylesheets/users.scss
@@ -0,0 +1,3 @@
// Place all the styles related to the users controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
8 changes: 8 additions & 0 deletions app/controllers/users_controller.rb
@@ -0,0 +1,8 @@
class UsersController < ApplicationController
def index
@users = User.order(created_at: :desc)
end

def edit
end
end
2 changes: 2 additions & 0 deletions app/helpers/users_helper.rb
@@ -0,0 +1,2 @@
module UsersHelper
end
3 changes: 2 additions & 1 deletion app/javascript/packs/application.js
Expand Up @@ -6,6 +6,7 @@
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("semantic-ui/dist/semantic").start()
require("channels")


Expand All @@ -14,4 +15,4 @@ require("channels")
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)
// const imagePath = (name) => images(name, true)
2 changes: 2 additions & 0 deletions app/views/users/edit.html.erb
@@ -0,0 +1,2 @@
<h1>Users#edit</h1>
<p>Find me in app/views/users/edit.html.erb</p>
20 changes: 20 additions & 0 deletions app/views/users/index.html.erb
@@ -0,0 +1,20 @@
<div class="main ui container">
<table class="ui purple table">
<thead>
<tr>
<th>ID</th>
<th>이름</th>
<th>email</th>
</tr>
</thead>
<tbody>
<% @users.each do |user| %>
<tr>
<td><%= user.id %></td>
<td><%= user.name %></td>
<td><%= user.email %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
6 changes: 4 additions & 2 deletions app/views/welcome/index.html.erb
@@ -1,2 +1,4 @@
<h1>Welcome#index</h1>
<p>Find me in app/views/welcome/index.html.erb</p>
<div class="">
<%= link_to '로그인', user_session_path %>
<%= link_to '로그아웃', destroy_user_session_path, method: :delete %>
</div>
5 changes: 5 additions & 0 deletions config/initializers/routing.rb
@@ -0,0 +1,5 @@
class ActionDispatch::Routing::Mapper
def draw_routes(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
8 changes: 6 additions & 2 deletions config/routes.rb
@@ -1,5 +1,9 @@
Rails.application.routes.draw do
Rails.application.routes.draw do
devise_for :users
resources :users

draw_routes :admin

get 'welcome/index'
root 'welcome#index'
root 'welcome#index'
end
3 changes: 3 additions & 0 deletions config/routes/admin.rb
@@ -0,0 +1,3 @@
scope :admin do
resources :users
end
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -7,7 +7,7 @@
"@rails/ujs": "^6.0.0-alpha",
"@rails/webpacker": "^4.0.7",
"turbolinks": "^5.2.0",
"bulma": "0.7.5"
"semantic-ui": "2.4.2"
},
"version": "0.1.0",
"devDependencies": {
Expand Down
14 changes: 14 additions & 0 deletions test/controllers/users_controller_test.rb
@@ -0,0 +1,14 @@
require 'test_helper'

class UsersControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get users_index_url
assert_response :success
end

test "should get edit" do
get users_edit_url
assert_response :success
end

end