logout
This commit is contained in:
parent
ec6ca60887
commit
af6f2668e6
14 changed files with 60 additions and 5 deletions
3
app/assets/javascripts/orders.js.coffee
Normal file
3
app/assets/javascripts/orders.js.coffee
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
3
app/assets/stylesheets/orders.css.scss
Normal file
3
app/assets/stylesheets/orders.css.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the Orders controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
13
app/controllers/orders_controller.rb
Normal file
13
app/controllers/orders_controller.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
class OrdersController < ApplicationController
|
||||
def new
|
||||
end
|
||||
|
||||
def show
|
||||
@user = User.find(params[:id])
|
||||
end
|
||||
|
||||
def create
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -14,6 +14,8 @@ class SessionsController < ApplicationController
|
|||
end
|
||||
|
||||
def destroy
|
||||
log_out
|
||||
redirect_to root_url
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -9,8 +9,9 @@ class UsersController < ApplicationController
|
|||
|
||||
def create
|
||||
@user = User.new(user_params)
|
||||
|
||||
if @user.save
|
||||
log_in @user
|
||||
flash[:success] = "Welcome to the Sample App!"
|
||||
redirect_to @user
|
||||
else
|
||||
render 'new'
|
||||
|
|
2
app/helpers/orders_helper.rb
Normal file
2
app/helpers/orders_helper.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
module OrdersHelper
|
||||
end
|
|
@ -11,4 +11,10 @@ module SessionsHelper
|
|||
def logged_in?
|
||||
!current_user.nil?
|
||||
end
|
||||
|
||||
def log_out
|
||||
session.delete(:user_id)
|
||||
@current_user = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
|
3
app/views/orders/new.html.erb
Normal file
3
app/views/orders/new.html.erb
Normal file
|
@ -0,0 +1,3 @@
|
|||
<h1>Orders#new</h1>
|
||||
<p>Find me in app/views/orders/new.html.erb</p>
|
||||
<p>In opbouw!</p>
|
1
app/views/orders/show.html.erb
Normal file
1
app/views/orders/show.html.erb
Normal file
|
@ -0,0 +1 @@
|
|||
<%= @user.name %>
|
|
@ -1,5 +1,6 @@
|
|||
<% @users.each do |user| %>
|
||||
<tr class="clickableRow" href= "order" >
|
||||
|
||||
<tr class="clickableRow" href= <%= "order"%> >
|
||||
<td><%= user.id %></td>
|
||||
<td><%= user.name %></td>
|
||||
<td><% user.marks.times do %>
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
<h1> order page </h1>
|
|
@ -1,20 +1,28 @@
|
|||
Rails.application.routes.draw do
|
||||
|
||||
get 'orders/new'
|
||||
|
||||
root 'static_pages#home'
|
||||
|
||||
get 'sessions/new'
|
||||
|
||||
get 'users/new'
|
||||
|
||||
get 'order' => 'static_pages#order'
|
||||
|
||||
get 'help' => 'static_pages#help'
|
||||
get 'static_pages/home'
|
||||
get 'overview' => 'static_pages#overview'
|
||||
get 'static_pages/overview'
|
||||
|
||||
#order stuff
|
||||
get 'order' => 'orders#new'
|
||||
post 'order' => 'orders#create'
|
||||
delete 'chaos' => 'orders#destroy'
|
||||
|
||||
|
||||
|
||||
#account stuff
|
||||
get 'signup' => 'users#new'
|
||||
|
||||
get 'login' => 'sessions#new'
|
||||
post 'login' => 'sessions#create'
|
||||
delete 'logout' => 'sessions#destroy'
|
||||
|
|
9
test/controllers/orders_controller_test.rb
Normal file
9
test/controllers/orders_controller_test.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
require 'test_helper'
|
||||
|
||||
class OrdersControllerTest < ActionController::TestCase
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
4
test/helpers/orders_helper_test.rb
Normal file
4
test/helpers/orders_helper_test.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
require 'test_helper'
|
||||
|
||||
class OrdersHelperTest < ActionView::TestCase
|
||||
end
|
Loading…
Reference in a new issue