Module: ShoppingCart::AddressesHelper

Defined in:
app/helpers/shopping_cart/addresses_helper.rb

Instance Method Summary collapse

Instance Method Details

#error?(type, field) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
# File 'app/helpers/shopping_cart/addresses_helper.rb', line 3

def error?(type, field)
  return unless correct_type?(type)

  @address.errors.include?(field)
end

#error_message(type, field) ⇒ Object



9
10
11
12
13
# File 'app/helpers/shopping_cart/addresses_helper.rb', line 9

def error_message(type, field)
  return unless correct_type?(type)

  @address.errors.messages[field][0] if @address
end

#saved_value(type, field) ⇒ Object



15
16
17
18
19
20
# File 'app/helpers/shopping_cart/addresses_helper.rb', line 15

def saved_value(type, field)
  address = address(type)
  return @address[field] if @address.try(:[], field) && correct_type?(type)

  address[field] if address
end