我怎样才能让它工作?使用 !!URI.parse(url) 还是 self.url ?
class Idea < ActiveRecord::Base
attr_accessible :body, :url
validates :body, presence: true, :length => { :in => 6..240 }
validates :body, uniqueness: true
validates :url, presence: true
validate :good_url
require 'uri'
def good_url
errors.add(:url, 'not valid') unless URI.parse(url)
end
end