Ruby on Rails Wednesday, October 28, 2015

On Thu, Oct 29, 2015 at 4:45 AM, Rodrigo Lueneberg <lists@ruby-forum.com> wrote:
> def is_valid_coordinate? # searches local geo_codes table for valid
> zip
> coord = self.full_target_area_coordinate.to_str

coord = self.to_str

> match = coord.match(/^(-?\d{1,2}\.\d{6}),\s*(-?\d{1,2}\.\d{6})$/)
> if match.nil? # invalid format
> errors.add(:target_area_coordinate, :invalid)

errors.add(self.to_sym, :invalid)


> return false
> end
>
> self.target_area_coordinate =
> UtilsModule.convert_coordinate(self.full_target_area_coordinate)

just return true here.
i would suggest separating the conversion from the validation.

kind regards,
--botp

> return true
> end
>
> end
>

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAAwHHQiQp3TF9kEb4kGU%3DfnLWN3%3DNnieR-Wuif1%3D%2B6cmnXr1aQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment