Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ./app/controllers/profiles_controller.rb
- class ProfilesController < ApplicationController
- ...
- private
- ...
- def invalid_address
- if hometown_attrs = profile_params[:hometown_attributes]
- hometown_attrs = hometown_attrs[:address_attributes].except(:id)
- end
- if residence_attrs = profile_params[:residence_attributes]
- residence_attrs = residence_attrs[:address_attributes].except(:id)
- end
- unless incomplete_address(hometown_attrs,residence_attrs)
- case
- when blank_address(hometown_attrs,residence_attrs),Geocoder.new(hometown_attrs).search,Geocoder.new(residence_attrs).search
- @profile.update(profile_params)
- return false
- end
- end
- true
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement