diff --git a/app/assets/images/.DS_Store b/app/assets/images/.DS_Store new file mode 100644 index 0000000..1b0d3a2 Binary files /dev/null and b/app/assets/images/.DS_Store differ diff --git a/app/assets/images/listing b/app/assets/images/listing new file mode 160000 index 0000000..3f67bbc --- /dev/null +++ b/app/assets/images/listing @@ -0,0 +1 @@ +Subproject commit 3f67bbc0f84539ba026e4909272654105dc53293 diff --git a/app/controllers/listings_controller.rb b/app/controllers/listings_controller.rb index 54659af..708e353 100644 --- a/app/controllers/listings_controller.rb +++ b/app/controllers/listings_controller.rb @@ -73,6 +73,6 @@ class ListingsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def listing_params - params.require(:listing).permit(:photo, :address, :property_type, :number_of_bedrooms, :number_of_bathrooms, :max_price_per_week, :available_date, :roles) + params.require(:listing).permit(:photo, :photo2, :photo3, :photo4, :photo5, :address, :property_type, :number_of_bedrooms, :number_of_bathrooms, :max_price_per_week, :available_date, :roles) end end diff --git a/app/models/listing.rb b/app/models/listing.rb index bbc3a0d..f160940 100644 --- a/app/models/listing.rb +++ b/app/models/listing.rb @@ -1,4 +1,8 @@ class Listing < ApplicationRecord attr_accessor :photo mount_uploader :photo, PhotosForListingsUploader + mount_uploader :photo2, PhotosForListingsUploader + mount_uploader :photo3, PhotosForListingsUploader + mount_uploader :photo4, PhotosForListingsUploader + mount_uploader :photo5, PhotosForListingsUploader end diff --git a/app/views/listings/_form.html.erb b/app/views/listings/_form.html.erb index 3b250e0..e8f2a2f 100644 --- a/app/views/listings/_form.html.erb +++ b/app/views/listings/_form.html.erb @@ -14,7 +14,6 @@
<%= form.label :photo %> <%= form.file_field :photo%> -
diff --git a/app/views/listings/index.html.erb b/app/views/listings/index.html.erb index a9b351a..04ea356 100644 --- a/app/views/listings/index.html.erb +++ b/app/views/listings/index.html.erb @@ -2,67 +2,37 @@

Listings

- - + +
- + - <% @listings.each do |listing| %> - + <%= cl_image_tag listing.photo %> + <%= cl_image_tag listing.photo2 %> + <%= cl_image_tag listing.photo.inspect %> - -
-
-
-
- <%= link_to cl_image_tag(listing.photo_url, :class => "uploaded_photo"), listing %> - $<%= listing.max_price_per_week %> - fav -
-
- <%= listing.number_of_bedrooms %> - <%= listing.number_of_bathrooms %> - <%= listing.max_price_per_week %> -

I am a very simple card. I am good at containing small bits of information. I am convenient because I require little markup to use effectively.

-
-
+ +
-
- + + + <% end %> - - - -
+ +
diff --git a/app/views/listings/show.html.erb b/app/views/listings/show.html.erb index e57113c..43b54c7 100644 --- a/app/views/listings/show.html.erb +++ b/app/views/listings/show.html.erb @@ -5,25 +5,6 @@ <%= cl_image_tag(@listing.photo_url, :class => "uploaded_photo") %>

-

-Photo3: -<%= cl_image_tag(@listing.photo3_url, :class => "uploaded_photo") %> -

- -

-Photo4: -<%= cl_image_tag(@listing.photo4_url, :class => "uploaded_photo") %> -

- -

-Photo5: -<%= cl_image_tag(@listing.photo5_url, :class => "uploaded_photo") %> -

- -

-Photo6: -<%= cl_image_tag(@listing.photo6_url, :class => "uploaded_photo") %> -

Address: diff --git a/db/migrate/20171103081805_create_listings.rb b/db/migrate/20171103081805_create_listings.rb index bcdd9ec..5d68268 100644 --- a/db/migrate/20171103081805_create_listings.rb +++ b/db/migrate/20171103081805_create_listings.rb @@ -2,13 +2,17 @@ class CreateListings < ActiveRecord::Migration[5.1] def change create_table :listings do |t| t.text :photo + t.text :photo2 + t.text :photo3 + t.text :photo4 + t.text :photo5 t.string :address t.string :property_type t.integer :number_of_bedrooms t.integer :number_of_bathrooms - t.integer :max_price_per_week - t.integer :available_date - t.integer :roles + t.integer :rent_price_per_week + t.integer :available_date #add jquery calendar + t.integer :user_id t.timestamps end diff --git a/db/schema.rb b/db/schema.rb index 8ae13a3..3cb8bbb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -24,13 +24,17 @@ ActiveRecord::Schema.define(version: 20171108052557) do create_table "listings", force: :cascade do |t| t.text "photo" + t.text "photo2" + t.text "photo3" + t.text "photo4" + t.text "photo5" t.string "address" t.string "property_type" t.integer "number_of_bedrooms" t.integer "number_of_bathrooms" - t.integer "max_price_per_week" + t.integer "rent_price_per_week" t.integer "available_date" - t.integer "roles" + t.integer "user_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false end diff --git a/db/seeds.rb b/db/seeds.rb index 1beea2a..68bed98 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,7 +1,19 @@ -# This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). -# -# Examples: -# -# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) -# Character.create(name: 'Luke', movie: movies.first) + +User.create!(email: "najomar68@gmail.com",password: "123456") +User.create!(email: "kevin@gmail.com", password: "123456") +User.create!(email: "takuya@gmail.com", password: "123456") + + +10.times do |post| +Listing.create!( + photo: File.open(Rails.root+"app/assets/images/listing/photo1.jpg"), + photo2: File.open(Rails.root+"app/assets/images/listing/photo2.jpg"), + photo3: File.open(Rails.root+"app/assets/images/listing/photo3.jpg"), + photo4: File.open(Rails.root+"app/assets/images/listing/photo4.jpg"), + photo5: File.open(Rails.root+"app/assets/images/listing/photo5.jpg"), + number_of_bedrooms: 2 , + rent_price_per_week: 500 , + available_date: 20160809, + user_id: 1 +) +end diff --git a/public/uploads/tmp/1510220920-13442-0001-6270/photo1.jpg b/public/uploads/tmp/1510220920-13442-0001-6270/photo1.jpg new file mode 100644 index 0000000..7f628cd Binary files /dev/null and b/public/uploads/tmp/1510220920-13442-0001-6270/photo1.jpg differ