Class: SimpleAddress::Street
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SimpleAddress::Street
- Defined in:
- app/models/simple_address/street.rb
Class Method Summary collapse
Instance Method Summary collapse
- #city_name ⇒ Object
- #city_name=(value) ⇒ Object
- #country_id ⇒ Object
- #country_id=(value) ⇒ Object
- #country_name ⇒ Object
- #region_name ⇒ Object
- #region_name=(value) ⇒ Object
Class Method Details
.search(params) ⇒ Object
7 8 9 10 11 |
# File 'app/models/simple_address/street.rb', line 7 def self.search(params) where(city_id: params[:city_id]).where( 'name LIKE ?', "#{params[:name]}%" ) end |
Instance Method Details
#city_name ⇒ Object
13 14 15 |
# File 'app/models/simple_address/street.rb', line 13 def city_name value_of :name end |
#city_name=(value) ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/models/simple_address/street.rb', line 17 def city_name=(value) if city city.update(name: value) else self.city = City.where(name: value).first_or_create end end |
#country_id ⇒ Object
29 30 31 |
# File 'app/models/simple_address/street.rb', line 29 def country_id value_of :country_id end |
#country_id=(value) ⇒ Object
25 26 27 |
# File 'app/models/simple_address/street.rb', line 25 def country_id=(value) set_city country_id: value end |
#country_name ⇒ Object
33 34 35 |
# File 'app/models/simple_address/street.rb', line 33 def country_name value_of :country_name end |
#region_name ⇒ Object
37 38 39 |
# File 'app/models/simple_address/street.rb', line 37 def region_name value_of :region_name end |
#region_name=(value) ⇒ Object
41 42 43 |
# File 'app/models/simple_address/street.rb', line 41 def region_name=(value) set_city region_name: value end |