def search @videos = Video.where("videoid LIKE ? or title LIKE ?", "%#{params[:q]}%", "%#{params[:q]}%") render :index end
使用 hash 的写法
def search @videos = Video.where("videoid LIKE :q or title LIKE :q", q: "%#{params[:q]}%") render :index end
def search @videos = Video.where("videoid LIKE ? or title LIKE ?", "%#{params[:q]}%", "%#{params[:q]}%") render :index end
使用 hash 的写法
def search @videos = Video.where("videoid LIKE :q or title LIKE :q", q: "%#{params[:q]}%") render :index end
转载于:https://www.cnblogs.com/iwangzheng/p/6164095.html