Skip to content

Commit

Permalink
links to different pages
Browse files Browse the repository at this point in the history
  • Loading branch information
christophwong committed Oct 6, 2018
1 parent 13e2a8b commit 3ffede8
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
1 change: 0 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
class ApplicationController < ActionController::Base
before_action :authenticate_user!
end
3 changes: 3 additions & 0 deletions app/controllers/static_pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
class StaticPagesController < ApplicationController

def home
@signed_in = user_signed_in?
end

def members_only

end

def admin_only
Expand Down
34 changes: 24 additions & 10 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<title>SignIn</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<head>
<title>SignIn</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>

<body>
<%= yield %>
</body>
<body>
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
<nav>
<ul>
<li><%= link_to "home", root_path %></li>
<li><%= link_to "members area", static_pages_members_only_path %></li>
<li><%= link_to "admin area", static_pages_admin_only_path %></li>
<% if user_signed_in? %>
<li><%= link_to "Sign Out", destroy_user_session_path, method: :delete %></li>
<% else %>
<li> <%= link_to "Sign In", new_user_session_path %> </li>
<% end %>
</ul>
</nav>
<%= yield %>
</body>
</html>
2 changes: 1 addition & 1 deletion app/views/static_pages/home.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<h1>StaticPages#home</h1>
<p>Find me in app/views/static_pages/home.html.erb</p>
<p> Is the user signed in? : <%= @signed_in ? "YES!" : "no :(" %> </p>
8 changes: 4 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Rails.application.routes.draw do
get 'static_pages/home'
get 'static_pages/members_only'
get 'static_pages/admin_only'
root to: "home#index"
get 'static_pages/home'
get 'static_pages/members_only'
get 'static_pages/admin_only'
root to: "static_pages#home"
devise_for :users
end

0 comments on commit 3ffede8

Please sign in to comment.