王筝的博客
ruby学习

 

  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

 

Leave a Reply