mirror of
https://github.com/kingomarnajjar/curly-happiness.git
synced 2026-07-25 22:27:18 +10:00
fixed multiple uploads
This commit is contained in:
parent
dc099b4f9e
commit
c67de55355
11 changed files with 59 additions and 84 deletions
BIN
app/assets/images/.DS_Store
vendored
Normal file
BIN
app/assets/images/.DS_Store
vendored
Normal file
Binary file not shown.
1
app/assets/images/listing
Submodule
1
app/assets/images/listing
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 3f67bbc0f84539ba026e4909272654105dc53293
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
<div class="field">
|
||||
<%= form.label :photo %>
|
||||
<%= form.file_field :photo%>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
|
|
|
|||
|
|
@ -2,67 +2,37 @@
|
|||
|
||||
<h1>Listings</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
<head>
|
||||
<div class="responsive-table highlight">
|
||||
|
||||
</div>
|
||||
</thead>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<% @listings.each do |listing| %>
|
||||
<!-- <div class="row">
|
||||
<div class="col s12 m6">
|
||||
<div class="card">
|
||||
<div class="card-image">
|
||||
<%= link_to cl_image_tag(listing.photo_url, :class => "uploaded_photo"), listing %>
|
||||
<span class="card-title">Card Title</span>
|
||||
<a class="btn-floating halfway-fab waves-effect waves-light red"><i class="material-icons">fav</i></a>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<p>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.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<%= cl_image_tag listing.photo %>
|
||||
<%= cl_image_tag listing.photo2 %>
|
||||
<%= cl_image_tag listing.photo.inspect %>
|
||||
|
||||
<!-- ########################################################################### -->
|
||||
<div class="row">
|
||||
<div class="col s12 m12 offset-m3">
|
||||
<div class="card">
|
||||
<div class="card-image">
|
||||
<%= link_to cl_image_tag(listing.photo_url, :class => "uploaded_photo"), listing %>
|
||||
<span class="card-title">$<%= listing.max_price_per_week %></span>
|
||||
<a class="btn-floating halfway-fab waves-effect waves-light red"><i class="material-icons">fav</i></a>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<%= listing.number_of_bedrooms %>
|
||||
<%= listing.number_of_bathrooms %>
|
||||
<%= listing.max_price_per_week %>
|
||||
<p>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.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="carousel">
|
||||
<a class="carousel-item" href="#one!"><"<%= cl_image_tag listing.photo_url %>"></a>
|
||||
<a class="carousel-item" href="#two!"><"<%= image_tag listing.photo_url %>"></a>
|
||||
<a class="carousel-item" href="#three!"><"<%= image_tag listing.photo_url %>"></a>
|
||||
<a class="carousel-item" href="#four!"><"<%= image_tag listing.photo_url %>"></a>
|
||||
<a class="carousel-item" href="#five!"><"<%= image_tag listing.photo_url%>"></a>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- <tr>
|
||||
<td><%= listing.address %></td>
|
||||
<td><%= listing.property_type %></td>
|
||||
<td><%= listing.number_of_bedrooms %></td>
|
||||
<td><%= listing.number_of_bathrooms %></td>
|
||||
<td><%= listing.max_price_per_week %></td>
|
||||
<td><%= listing.available_date %></td>
|
||||
<td><%= listing.roles %></td>
|
||||
<td><%= link_to 'Show', listing %></td>
|
||||
<td><%= link_to 'Edit', edit_listing_path(listing) %></td>
|
||||
<td><%= link_to 'Destroy', listing, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr> -->
|
||||
|
||||
<script type="text/javascript">
|
||||
$('.carousel.carousel-slider').carousel({fullWidth: true});
|
||||
</script>
|
||||
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,25 +5,6 @@
|
|||
<%= cl_image_tag(@listing.photo_url, :class => "uploaded_photo") %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Photo3:</strong>
|
||||
<%= cl_image_tag(@listing.photo3_url, :class => "uploaded_photo") %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Photo4:</strong>
|
||||
<%= cl_image_tag(@listing.photo4_url, :class => "uploaded_photo") %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Photo5:</strong>
|
||||
<%= cl_image_tag(@listing.photo5_url, :class => "uploaded_photo") %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Photo6:</strong>
|
||||
<%= cl_image_tag(@listing.photo6_url, :class => "uploaded_photo") %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Address:</strong>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
26
db/seeds.rb
26
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
|
||||
|
|
|
|||
BIN
public/uploads/tmp/1510220920-13442-0001-6270/photo1.jpg
Normal file
BIN
public/uploads/tmp/1510220920-13442-0001-6270/photo1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 540 KiB |
Loading…
Add table
Reference in a new issue