Sha256: 31b06319e6d54b33b9152cf944ff16f27dcf2e8401865a974268b5afe3c946c0

Contents?: true

Size: 732 Bytes

Versions: 40

Compression:

Stored size: 732 Bytes

Contents

# rake db:seed:60_fill_atypes

arr = [
    {
        id: 1,
        title: 'Здание',
        props: ['Высота потолков', 'Цена за м.кв.']
    },
    {
        id: 2,
        title: 'Складское помещение',
        props: ['Высота потолков', 'Цена за м.кв.', 'Шаг колонн', 'Тип ворот']
    },
    {
        id: 3,
        title: 'Офис',
        props: ['Цена за м.кв.']
    }
]

C80Estate::Atype.delete_all
arr.each do |elem|
  at = C80Estate::Atype.create!({ id:elem[:id], title:elem[:title] })
  elem[:props].each do |prop_title|
    p = C80Estate::PropName.where(:title => prop_title).first
    at.prop_names << p
  end
  at.save
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
c80_estate-0.1.0.39 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.38 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.37 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.36 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.35 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.34 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.33 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.32 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.31 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.30 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.29 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.28 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.27 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.26 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.25 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.24 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.23 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.22 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.21 db/seeds/60_fill_atypes.rb.example
c80_estate-0.1.0.20 db/seeds/60_fill_atypes.rb.example