Commit f6f9b9f7 by Thanh Hung Pham

Add login and register page

parent edb5e7ba
# 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/
// Place all the styles related to the Sessions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
class SessionsController < ApplicationController
def new
end
def create
render 'new'
end
end
...@@ -2,4 +2,8 @@ class UsersController < ApplicationController ...@@ -2,4 +2,8 @@ class UsersController < ApplicationController
def new def new
@user = User.new @user = User.new
end end
def login
@user = User.new
end
end end
module SessionsHelper
end
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<%= link_to image_tag('', alt: 'veNJOB'), root_path, id: 'logo' %> <%= link_to image_tag('', alt: 'veNJOB'), root_path, id: 'logo' %>
<nav> <nav>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li> <%= link_to 'Login', '#' %> </li> <li> <%= link_to 'Login', login_path %> </li>
<li> <%= link_to 'Register', register_path %> </li> <li> <%= link_to 'Register', register_path %> </li>
<li> <%= link_to 'Favorite', '#' %> </li> <li> <%= link_to 'Favorite', '#' %> </li>
<li> <%= link_to 'History', '#' %> </li> <li> <%= link_to 'History', '#' %> </li>
......
<%- provide(:title, 'Login') -%>
<div class="well">
<h2>Log in</h2>
<%= form_for(:session, url: login_path) do |f| %>
<div class="row">
<div class="col-md-2 col-md-offset-3">
<%= f.label :email %>
</div>
<div class="col-md-6">
<%= f.email_field :email, size: 50, maxlength: 255, class: 'form_control' %>
</div>
</div>
<div class="row">
<div class="col-md-2 col-md-offset-3">
<%= f.label :password %>
</div>
<div class="col-md-6">
<%= f.password_field :password, size: 50, maxlength: 255, class: 'form_control' %>
</div>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-5">
<%= link_to 'Forgot password?', '#' %>
</div>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-5">
<%= f.submit 'Log in', class: 'btn btn-primary' %>
<%= link_to 'Register', register_path, class: 'btn btn-primary' %>
</div>
</div>
<%- end -%>
</div>
<%- provide(:title, 'Register') -%> <%- provide(:title, 'Register') -%>
<h1>Register</h1> <div class="well">
<div class="row"> <h2>Register</h2>
<div class="col-md-6 col-md-offset-3">
<%= form_for(@user) do |f| %> <%= form_for(@user) do |f| %>
<%= f.label :email %> <div class="row">
<%= f.email_field :email %> <div class="col-md-6 col-md-offset-3">
<%= f.label :email%>
<%= f.email_field :email, size: 50, maxlength: 255 %>
</div>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-5">
<%= f.submit 'Confirm your email', class: 'btn btn-primary' %> <%= f.submit 'Confirm your email', class: 'btn btn-primary' %>
<%- end -%>
</div> </div>
</div>
<%- end -%>
</div> </div>
Rails.application.routes.draw do Rails.application.routes.draw do
root 'static_pages#home' root 'static_pages#home'
get 'static_pages/home' get 'static_pages/home'
...@@ -7,6 +6,10 @@ Rails.application.routes.draw do ...@@ -7,6 +6,10 @@ Rails.application.routes.draw do
get '/cities', to: 'cities#show' get '/cities', to: 'cities#show'
get '/categories', to: 'categories#show' get '/categories', to: 'categories#show'
get '/login', to: 'sessions#new'
post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy'
resource :users resource :users
resource :cities resource :cities
......
require 'test_helper'
class SessionsControllerTest < ActionDispatch::IntegrationTest
test "should get new" do
get sessions_new_url
assert_response :success
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment