diff --git a/app/models/enterprise_group.rb b/app/models/enterprise_group.rb index 5b3b65e311..9a398e8c39 100644 --- a/app/models/enterprise_group.rb +++ b/app/models/enterprise_group.rb @@ -12,6 +12,7 @@ class EnterpriseGroup < ActiveRecord::Base attr_accessible :name, :description, :long_description, :on_front_page, :enterprise_ids attr_accessible :logo, :promo_image + attr_accessible :address_attributes attr_accessible :email, :website, :facebook, :instagram, :linkedin, :twitter delegate :phone, :to => :address @@ -37,7 +38,7 @@ class EnterpriseGroup < ActiveRecord::Base scope :on_front_page, where(on_front_page: true) def set_unused_address_fields - address.firstname = address.lastname = address.phone = 'unused' if address.present? + address.firstname = address.lastname = 'unused' if address.present? end end diff --git a/app/views/admin/enterprise_groups/_inputs.html.haml b/app/views/admin/enterprise_groups/_inputs.html.haml index fabebdaef4..8b2db582a9 100644 --- a/app/views/admin/enterprise_groups/_inputs.html.haml +++ b/app/views/admin/enterprise_groups/_inputs.html.haml @@ -52,9 +52,10 @@ %legend Contact .row .alpha.three.columns - = f.label :phone + = af.label :phone + %span.required * .omega.eight.columns - = f.text_field :phone, { placeholder: "eg. 98 7654 3210"} + = af.text_field :phone, { placeholder: "eg. 98 7654 3210"} .row .three.columns.alpha = af.label :address1 diff --git a/db/migrate/20150115050936_add_address_instances_to_existing_enterprise_groups.rb b/db/migrate/20150115050936_add_address_instances_to_existing_enterprise_groups.rb new file mode 100644 index 0000000000..2978d286dc --- /dev/null +++ b/db/migrate/20150115050936_add_address_instances_to_existing_enterprise_groups.rb @@ -0,0 +1,14 @@ +class AddAddressInstancesToExistingEnterpriseGroups < ActiveRecord::Migration + def change + country = Spree::Country.find_by_name(ENV['DEFAULT_COUNTRY']) + state = country.states.first + EnterpriseGroup.all.each do |g| + if g.address.present? then + next + end + address = Spree::Address.new(firstname: 'unused', lastname: 'unused', address1: 'undefined', city: 'undefined', zipcode: 'undefined', state: state, country: country, phone: 'undefined') + g.address = address + g.save + end + end +end