251: MetaWhereとMetaSearch (view original Railscast) Other translations: Other formats: Written by Naomi Fujimoto 下の図は、product(商品)の一覧を表示する簡単なRails 3アプリケーションのスクリーンショットです。このページには、商品を名前で絞り込むための検索フォームがあります。 検索はProductsController内のindexアクションで実行されます。コードは以下のようになります。 /app/controllers/products_controller.rb def index @products = Product.where("name LIKE ?", "%#{params[:search]}%") end SQL句を含むwhereメソッドで、商品