# URI::MailTo::EMAIL_REGEXP adapted for postgres
EMAIL_REGEX = %Q(\\A[a-zA-Z0-9.!#$%&''*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\\Z)
POPULAR_DOMAINS = %w[gmail yahoo hotmail]
def pluck_email(relation)
relation.pluck(Arel.sql(%Q(data->>'email')))
end
# before state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"Acura":{"MDX":{"years":["2001","2002","2003","2004","2005","2006","2007","2008","2009","2010","2011","2012","2013","2014","2015","2016","2017","2018","2019","2020","2022","2023"]},"RDX":{"years":["2007","2008","2009","2010","2011","2012","2013","2014","2015","2016","2017","2018","2019","2020","2021","2022","2023"]},"RL":{"years":["1996","1997","1998","1999","2000","2001","2002","2003","2004","2005","2006","2007","2008","2009","2010","2011","2012"]},"TL":{"years":["1995","1996","1997","1998","1999","2000","2001","2002","2003","2004","2005","2006","2007","2008","2009","2010","2011","2012","2013","2014"]},"TSX":{"years":["2004","2005","2006","2007","2008","2009","2010","2011","2012","2013","2014"]},"ZDX":{"years":["2010","2011","2012","2013"]},"Integra":{"years":["1992","1993","1994","1995","1996","1997","1998","1999","2000","2001","2023"]},"NSX":{"years":["1992","1993","1994","1995","1996","1997","1998","1999","2000","2001","2002","2003","2004","2005","2017","2018","2019","2020","2021","2022"]},"SLX":{"years" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Post < ActiveRecord::Base | |
has_many :comments | |
belongs_to :user | |
belongs_to :topic | |
default_scope { order(created_at: :desc) } | |
validates :title, :body, :topic, :user, presence: true | |
validates :title, length: { minimum: 5 } | |
validates :body, length: { minimum: 20 } |