mirror of
https://github.com/publiclab/mapknitter.git
synced 2025-12-11 18:59:59 +01:00
Reorganize and consolidate templates (#558)
* add map and images seeds * add faker for faking and pry for debuggging * Remove will-paginate-bootstrap It is no longer maintained Center pagination bar Add will-paginate-bootstrap4 * add hidden overflow
This commit is contained in:
45
db/seeds.rb
45
db/seeds.rb
@@ -1,7 +1,38 @@
|
||||
# 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 rake db:seed (or created alongside the db with db:setup).
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
||||
# Mayor.create(name: 'Emanuel', city: cities.first)
|
||||
# Fake maps
|
||||
users = User.all
|
||||
p 'Now faking Maps....'
|
||||
maps = []
|
||||
30.times do
|
||||
map = Map.new(
|
||||
name: Faker::Address.city,
|
||||
lat: Faker::Address.latitude,
|
||||
lon: Faker::Address.longitude,
|
||||
location: Faker::Address.country,
|
||||
description: Faker::Lorem.sentence,
|
||||
slug: Faker::Lorem.word
|
||||
)
|
||||
map.user = (users.sample)
|
||||
map.author = map.user.login
|
||||
map.save
|
||||
maps. << map
|
||||
end
|
||||
p 'Done faking maps...'
|
||||
|
||||
|
||||
# Fake maps images
|
||||
p 'Adding Warbaples to maps'
|
||||
|
||||
maps.each do |map|
|
||||
image = map.warpables.new
|
||||
image.id = Faker::Number.unique.between(10, 100)
|
||||
image.history = Faker::Lorem.word
|
||||
image.image_file_name = 'demo.png'
|
||||
image.width = 500
|
||||
image.nodes = '1,3,4,5'
|
||||
system("mkdir -p public/system/images/#{image.id}/original")
|
||||
system("cp test/fixtures/demo.png public/system/images/#{image.id}/original/demo.png")
|
||||
image.image_content_type = 'image/png'
|
||||
image.save
|
||||
end
|
||||
p 'Done adding images to maps'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user