Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,24 @@ class ApplicationController < Sinatra::Base
end

get "/" do
erb :welcome
if logged_in?
redirect '/bix_plans'
else
erb :welcome
end
end

helpers do

def logged_in?
!!current_user
end

def current_user
@current_user ||= User.find_by_id(session[:user_id]) if session[:user_id]
# uses memoization to prevent duplicate database queries
end

end

end
end
8 changes: 4 additions & 4 deletions app/views/biz_plans/index.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

<% @biz_plans.each do |biz_plan| %>
<div class="post">
<p><%= biz_plan.name %> by <%= biz_plan.user.username %></p>
<h3><%= biz_plan.name %></h3> by <p><%= biz_plan.user.username %></p>
<% if biz_plan.user == current_user %>
<p><a href="/biz_plans/<%= biz_plan.id %>/edit">Edit</a></p>

<form action="/biz_plans/<%= biz_plan.id %>" method='post'>
<input type="hidden" name="_method" value="delete">
<input type="submit" value="Delete">
</form>

<% end %>
</div>
<% end %>
<p><a href="/biz_plans/new">Add a Business Plan</a></p>
<p><a href="/biz_plans/new">Add a Business Plan</a></p>
9 changes: 6 additions & 3 deletions app/views/layout.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
<div class="wrapper">
<h3> Show Off Your Business with BizUs App </h3>
<%= yield %>
<p><a href='/signup'>Signup</a></p>
<p><a href='/login'>Login</a></p>
<p><a href='logout'>Logout</a></p>
<% if logged_in? %>
<p><a href='logout'>Logout</a></p>
<% else %>
<p><a href='/signup'>Signup</a></p>
<p><a href='/login'>Login</a></p>
<% end %>
<footer class="branding">
<small>&copy; 2020 <strong>SinatraBizUs</strong></small>
</footer>
Expand Down
4 changes: 2 additions & 2 deletions config/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:database => "db/#{ENV['SINATRA_ENV']}.sqlite"
)

require_relative '../secrets'
# require_relative '../secrets'

require './app/controllers/application_controller'
require_all 'app'
require_all 'app'
Binary file modified db/development.sqlite
Binary file not shown.
19 changes: 15 additions & 4 deletions public/stylesheets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@
}
.post {
padding: 10px;
border: solid 5px black;
border-radius: 5px;

border: solid 5px #36454f;
border-radius: 10px;
width: 40%;
margin: auto;
margin-bottom: 10px;
background-color: #3d3d5c; /* slight purple */
color: #fff; /* white */
}

.error {
Expand Down Expand Up @@ -137,4 +141,11 @@
.error {
color: red;
}
}
}

a:link {
color: #3377ff;
}
a:visited {
color: #a31aff;
}