post.rb
@allowed_post_types = [
'type1',
'type2',
'type3',
'type4'
]
#validate post type
validates :post_type, :presence => true, :inclusion=> { :in => @allowed_post_types }, :if => :valid_post_type?
def valid_post_type?
self.post_type != 'type5'
end
how can i enable validates :post_type line of code whenever the :post_type is not type5 ?
Tried the above but it doesn’t seem to work
Try: