我有这样的AR代码:
@types = Type.find(:all,
:conditions => { :TYP_MOD_ID => params[:models],
:TYP_PCON_START => params[:year] },
:order => "TYP_HP_FROM")
但我怎么能这样做,我看到TYP_PCON_START
没有前2个符号并进行比较?
例如:TYP_PCON_START.to_s[4...6]
另外我需要比较not =,但是> =>条件。怎么做?
答案 0 :(得分:1)
使用where
代替find
。我也不明白你的意思how can i do that i see TYP_PCON_START without first 2 symbols and compare?
。
@types = Type.where("TYP_MOD_ID = ? AND substring(TYP_PCON_START FROM 4 to 6) >= ?",
params[:models], params[:year]).order("TYP_HP_FROM")