ruby - validating only itunes app store and play store url in rails -



ruby - validating only itunes app store and play store url in rails -

i having simple problem validating url using ruby on rails technology.there alot of solution validating url none works me.as want allow play store , app store url save in database.

say have play store app link. here model:

class appstore < activerecord::base validate :custom private def custom if self.url_name.match /paly.google.com|itunes.apple.com/ else self.errors.add(:url_name, 'must app store url or paly store url') end end end

now when come in url "http://play.google.com" total url of app validation failling. sample url https://play.google.com/store/apps/details?id=com.viber.voip

please help me solve problem as.i new rails technology. give thanks guys.

please seek following:

class appstore < activerecord::base valid_stores = ['play.google.com', 'itunes.apple.com'] validate :store_url_format private def store_url_format unless valid_stores.any? { |host| url_name.includes?(host) } errors.add(:url_name, 'must appstore or playstore url') end end end

ruby ruby-on-rails-3 validation

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -