Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ruby on Rails para Iniciantes - Aula 40
Search
Jackson Pires
May 19, 2015
Programming
0
260
Ruby on Rails para Iniciantes - Aula 40
Criando pesquisas com o Ransack (Básico) 40
Jackson Pires
May 19, 2015
Tweet
Share
More Decks by Jackson Pires
See All by Jackson Pires
Como usar uma box Vagrant com a Cloud9 IDE para desenvolver com Elixir ou Phoenix?
jackson_pires
0
77
Conhecendo o módulo Forwardable do Ruby
jackson_pires
0
65
COMO INSPIRAR PESSOAS E MONETIZAR O SEU CONHECIMENTO?
jackson_pires
0
54
Conhecendo a gem guard, guard-rspec e guard-livereload
jackson_pires
0
80
GDG Meetup - Carreiras em T.I.
jackson_pires
0
76
20 minutos insanos de TDD e Ruby
jackson_pires
0
110
Ruby on Rails para Iniciantes - Aula 46
jackson_pires
0
160
Ruby on Rails para Iniciantes - Aula 47
jackson_pires
0
80
Ruby on Rails para Iniciantes - Aula 48
jackson_pires
0
370
Other Decks in Programming
See All in Programming
Code as Context 〜 1にコードで 2にリンタ 34がなくて 5にルール? 〜
yodakeisuke
0
120
Node-RED を(HTTP で)つなげる MCP サーバーを作ってみた
highu
0
120
Go1.25からのGOMAXPROCS
kuro_kurorrr
1
840
Discover Metal 4
rei315
2
110
datadog dash 2025 LLM observability for reliability and stability
ivry_presentationmaterials
0
410
ふつうの技術スタックでアート作品を作ってみる
akira888
0
290
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
50
32k
NPOでのDevinの活用
codeforeveryone
0
650
第9回 情シス転職ミートアップ 株式会社IVRy(アイブリー)の紹介
ivry_presentationmaterials
1
260
#kanrk08 / 公開版 PicoRubyとマイコンでの自作トレーニング計測装置を用いたワークアウトの理想と現実
bash0c7
1
660
PHP 8.4の新機能「プロパティフック」から学ぶオブジェクト指向設計とリスコフの置換原則
kentaroutakeda
2
700
Composerが「依存解決」のためにどんな工夫をしているか #phpcon
o0h
PRO
1
250
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
How to Ace a Technical Interview
jacobian
277
23k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.5k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
The World Runs on Bad Software
bkeepers
PRO
69
11k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.8k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.7k
Code Reviewing Like a Champion
maltzj
524
40k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
22k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
720
Optimizing for Happiness
mojombo
379
70k
Transcript
Ruby on Rails Para iniciantes - 3a Temporada \o/
http://videosdeti.com.br
[email protected]
Mentoring
Patrocinadores Roger Bernardi
Aula 40 Criando pesquisas com o Ransack (básico)
Ruby on Rails Index Customer Products Usuários Autenticados (normal_user, admin)
Addresses ControlUsers Usuários Autenticados (admin)
Ruby on Rails Products description quantity
Ruby on Rails Ransack
Ruby on Rails Adicione ao Gemfile... gem ‘ransack’
Ruby on Rails Rode o bundle install
Ruby on Rails Simple Mode
Ruby on Rails Helper search_form_for
Ruby on Rails Na View <%= search_form_for @q do |f|
%> <%= f.label :description_cont %> <%= f.search_field :description_cont %> <%= f.submit %> <% end %>
Ruby on Rails No Controller def index @q = Product.ransack(params[:q])
@products = @q.result end
Ruby on Rails Ordenando Colunas sort_link
Ruby on Rails Ordenando Colunas <%= sort_link(@q, :description) %>
Ruby on Rails Adicionando mais opções de pesquisa na view
Ruby on Rails Products description quantity
Ruby on Rails Adicionando mais opções de pesquisa na view
<%= f.label :quantity_lteq %> <%= f.search_field :quantity_lteq %>
Ruby on Rails Pesquisas não restritivas AND => OR def
index @q = Product.ransack(params[:q].try(:merge, m: 'or')) @products = @q.result end
Ruby on Rails Automatizando o E/OU Na view <%= f.select
:combinator, [[‘E’,’and’],[’OU’,’or’]], @q %> No controller @q = Product.ransack(params[:q].try(:merge, m: params[:combinator]))
Ruby on Rails Obrigado!