I’m new to RoR; I want create the following statement. I’ve an array; I want that controller return false if all array elements are not equal to a variable value.This is the code
def check_warehouse(asset,serial)
wh = Warehouse.where(["(asset = ? and serial = ?) OR (asset = ?) OR (serial= ?)",asset,serial,asset,serial])
return false if wh.count > 1
return false if
wh.each do |wh|
wh.position_id != session[:position_id]
end
end
but it doesn’t works!why?
Moreover, can you suggest me a plugin or gem running on Rails 3.1 for generate pdf from RoR datas?
Thank you all
Try smth like this:
I removed
return false if wh.count > 1because there’s no sense to check the array if you return if it has more than 1 element. Please tell me if I misunderstood youUPD
Actually you can do that in the db: