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
75
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
人には人それぞれのサービス層がある
shimabox
3
670
2度もゼロから書き直して、やっとブラウザでぬるぬる動くAIに辿り着いた話
tomoino
0
160
ワイがおすすめする新潟の食 / 20250530phpconf-niigata-eve
kasacchiful
0
300
從零到一:搭建你的第一個 Observability 平台
blueswen
1
890
[初登壇@jAZUG]アプリ開発者が気になるGoogleCloud/Azure+wasm/wasi
asaringo
0
130
Enterprise Web App. Development (2): Version Control Tool Training Ver. 5.1
knakagawa
1
110
Practical Tips and Tricks for Working with Compose Multiplatform Previews (mDevCamp 2025)
stewemetal
0
120
Bytecode Manipulation 으로 생산성 높이기
bigstark
1
290
AIエージェントによるテストフレームワーク Arbigent
takahirom
0
370
TypeScript LSP の今までとこれから
quramy
1
500
eBPFを用いたAIネットワーク監視システム論文の実装 / eBPF Japan Meetup #4
yuukit
3
750
レガシーシステムの機能調査・開発におけるAI利活用
takuya_ohtonari
0
590
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
56
9.4k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
123
52k
Scaling GitHub
holman
459
140k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Optimizing for Happiness
mojombo
379
70k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
137
34k
Git: the NoSQL Database
bkeepers
PRO
430
65k
Rebuilding a faster, lazier Slack
samanthasiow
81
9k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.7k
Adopting Sorbet at Scale
ufuk
77
9.4k
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!