Skip to content
Permalink
Browse files

Revert "Wip rails shrinking solution"

  • Loading branch information...
DanielSeehausen committed May 7, 2018
1 parent 0d7e32e commit bd450d9512e59b387896111a4ce98de2482026fd
@@ -62,5 +62,3 @@ end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'pry'
@@ -1,18 +1,3 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :verify_user_is_authenticated
helper_method :current_user

private
def verify_user_is_authenticated
redirect_to '/' unless user_is_authenticated
end

def user_is_authenticated
!!current_user
end

def current_user
User.find_by(id:session[:user_id])
end
end

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -1,4 +1,2 @@
class Attraction < ApplicationRecord
has_many :rides
has_many :users, :through => :rides
end
@@ -1,49 +1,2 @@
class Ride < ActiveRecord::Base
belongs_to :user
belongs_to :attraction

def take_ride
user_has_enough_tickets, user_is_tall_enough = check_if_user_meets_the_requirements
if user_has_enough_tickets && user_is_tall_enough
start_ride
elsif user_is_tall_enough && !user_has_enough_tickets
"Sorry. " + not_enough_tickets
elsif user_has_enough_tickets && !user_is_tall_enough
"Sorry. " + not_tall_enough
else
"Sorry. " + not_enough_tickets + " " + not_tall_enough
end
end

def check_if_user_meets_the_requirements
user_has_enough_tickets, user_is_tall_enough = false
if self.user.tickets >= self.attraction.tickets
user_has_enough_tickets = true
end
if self.user.height >= self.attraction.min_height
user_is_tall_enough = true
end
return [user_has_enough_tickets, user_is_tall_enough]
end

def start_ride
new_happiness = self.user.happiness + self.attraction.happiness_rating
new_nausea = self.user.nausea + self.attraction.nausea_rating
new_tickes_count = self.user.tickets - self.attraction.tickets
self.user.update(
:happiness => new_happiness,
:nausea => new_nausea,
:tickets => new_tickes_count
)
"Thanks for riding the #{self.attraction.name}!"
end

def not_enough_tickets
"You do not have enough tickets to ride the #{self.attraction.name}."
end

def not_tall_enough
"You are not tall enough to ride the #{self.attraction.name}."
end

end
end
@@ -1,13 +1,2 @@
class User < ApplicationRecord
has_secure_password
has_many :rides
has_many :attractions, through: :rides

def mood
# has a method 'mood' that returns 'sad' when the user is more nauseous than happy
# has a method 'mood' that returns 'happy' when the user is more happy than nauseous
unless admin
happiness > nausea ? 'happy' : 'sad'
end
end
class User < ActiveRecord::Base
end

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -18,15 +18,6 @@
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<%= root_url %>"/>Home</a>

<% if !current_user %>
<a class="navbar-brand" href="<%= new_user_path %>"/>Sign Up</a>
<%= link_to "Log in", signin_path, class:"navbar-brand" %>
<% end %>
<% if current_user %>
<%= link_to "#{current_user.name}'s profile", user_path(current_user), class:"navbar-brand"%>
<%= link_to "Log Out", session_path, class:"navbar-brand",method:'delete' %>
<% end %>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">

This file was deleted.

This file was deleted.

0 comments on commit bd450d9

Please sign in to comment.
You can’t perform that action at this time.