Skip to content

Commit

Permalink
Photo added to user model, seed user photos added, photos added to na…
Browse files Browse the repository at this point in the history
…vbar and vehicle show page
  • Loading branch information
corrieam committed May 17, 2019
1 parent cba1287 commit db6871d
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 5 deletions.
5 changes: 5 additions & 0 deletions app/assets/stylesheets/pages/_show.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@
top: -20px;
width: 40px;
}

.card-trip-user > img {
height: 42px;
border-radius: 50px;
}
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ class ApplicationController < ActionController::Base

def configure_permitted_parameters
# For additional fields in app/views/devise/registrations/new.html.erb
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name])
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :photo])
end
end
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
mount_uploader :photo, PhotoUploader
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
has_many :bookings, foreign_key: "renter_id", class_name: "Booking"
Expand Down
2 changes: 2 additions & 0 deletions app/views/devise/registrations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<%= f.input :password_confirmation,
required: true,
input_html: { autocomplete: "new-password" } %>
<%= f.input :photo %>
<%= f.input :photo_cache, as: :hidden %>
</div>

<div class="form-actions">
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ul class="navbar-nav mr-auto">
<% if user_signed_in? %>
<li class="nav-item dropdown">
<%= image_tag "https://kitt.lewagon.com/placeholder/users/ssaunier", class: "avatar dropdown-toggle", id: "navbarDropdown", data: { toggle: "dropdown" }, 'aria-haspopup': true, 'aria-expanded': false %>
<%= cl_image_tag current_user.photo, class: "avatar dropdown-toggle", id: "navbarDropdown", data: { toggle: "dropdown" }, 'aria-haspopup': true, 'aria-expanded': false %>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<%= link_to "Add Vehicle", new_user_vehicle_path(current_user), class: "dropdown-item" %>
<%= link_to "My Vehicles", user_vehicles_path(current_user), class: "dropdown-item" %>
Expand Down
4 changes: 3 additions & 1 deletion app/views/vehicles/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
<p>Berth: (<%= @vehicle.berths %>)</p>
</div>
<h2 class="card-trip-pricing"><%= @vehicle.price_per_night %></h2>
<img src='https://kitt.lewagon.com/placeholder/users/krokrob' class="card-trip-user avatar-bordered"/>
<div class="card-trip-user">
<%= cl_image_tag @vehicle.owner.photo, crop: :fill %>
</div>
<p>Category: <%= @vehicle.category %></p>
<p>Description: <%= @vehicle.description %></p>
</div>
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20190517110448_add_photo_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPhotoToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :photo, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2019_05_17_093105) do
ActiveRecord::Schema.define(version: 2019_05_17_110448) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand All @@ -36,6 +36,7 @@
t.datetime "updated_at", null: false
t.string "first_name"
t.string "last_name"
t.string "photo"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end
Expand Down
3 changes: 2 additions & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
first_name: Faker::Name.first_name,
last_name: Faker::Name.last_name,
email: Faker::Internet.email,
password: 123456
password: 123456,
remote_photo_url: "https://kitt.lewagon.com/placeholder/users/liamgarrison"
})
end

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit db6871d

Please sign in to comment.