Railsで検索を作る時ちょっと面倒臭いです。
EZ_Where, Where Plugin, CriteriaQueryなど、検索条件を書きやすくするプラグインがいくつかありますが、railswhereというプラグインは記述が簡潔で気に入りました。
timcharper’s railswhere at master ? GitHubWhere clause generator Building a complicated where clause made easy
インストール:
script/plugin install git://github.com/timcharper/railswhere.git
施設(Facility)の検索フォームで、
「都道府県」、「フリーワード」
で検索という場合、
where = Where.new
unless params[:prefecture_id].blank?
where.and('prefecture_id = ?', params[:prefecture_id])
end
unless params[:word].blank?
where.and(
Where.new("name LIKE ?", "%#{params[:word]}%").
or("description LIKE ?", "%#{params[:word]}%")
)
end
@facilities = Facility.paginate(
:page => params[:page],
:conditions => where.to_s)
という感じです。(ちょw%%かよ!はスルーで)
パッと見だけで使い方がわかるのがうれしい。
※間違ってたので修正しました。簡単に条件を入れ子にできるのもいいですね。
Анализ таких ресурсов, как Safeeds Transport Inc BBB (или просто BBB Safeeds Transport Inc) и Safeeds Transport Inc Yelp, дает возможность учесть все риски, но и на основе реального опыта других клиентов, а также заметно раскрыть честное отношение в условиях международных перевозок.
•: https://safeedsautotransport.com/
Muchos expertos recomiendan planificar estos detalles con antelacion, buscando siempre la mayor eficiencia urbana. He encontrado varios hilos y articulos que analizan estos temas a fondo::
Link- https://pub37.bravenet.com/forum/static/show.php?usernum=3126278401&frmid=18&msgid=1605811&cmd=show
?Disfruten la ciudad sin cargas!