Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. # ./app/controllers/profiles_controller.rb
  2. class ProfilesController < ApplicationController
  3. ...
  4.  
  5. private
  6. ...
  7. def invalid_address
  8. if hometown_attrs = profile_params[:hometown_attributes]
  9. hometown_attrs = hometown_attrs[:address_attributes].except(:id)
  10. end
  11. if residence_attrs = profile_params[:residence_attributes]
  12. residence_attrs = residence_attrs[:address_attributes].except(:id)
  13. end
  14.  
  15. unless incomplete_address(hometown_attrs,residence_attrs)
  16. case
  17. when blank_address(hometown_attrs,residence_attrs),Geocoder.new(hometown_attrs).search,Geocoder.new(residence_attrs).search
  18. @profile.update(profile_params)
  19. return false
  20. end
  21. end
  22.  
  23. true
  24. end
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement