How to validate a jquery autocomplete in my Rails App? -


my simple rails app has model 2 methods:

:from :to

i use awesome (google maps api) powered address-rails-picker app :to , :from in form automplete location user types in.

i have trouble in writing validation forces user choose autocomplete location instead of writing gibberish user wants.

i figured porablly need use callback. here code far:

   class post < activerecord::base     attr_accessible :from, :to     validates :from, :presence => true, confirmation: true     validates :to, :presence => true      before_validation     self.from = from.find_by_address-picker-input(from)     self.to = to.find_by_address-picker-input(to)        end      end 

any appreciated.

you can't rails only, since address picker pure javascript. 1 way can think of add hidden field acting flag. , set flag if user manually change input field. validate flag.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -