# Una semplice ricerca in rails su tabelle mirate

**URL:** <https://www.ruby-forum.com/t/una-semplice-ricerca-in-rails-su-tabelle-mirate/190355>\
**Category:** IT\
**Created:** [June 18, 2010, 12:06pm UTC](https://www.ruby-forum.com/t/una-semplice-ricerca-in-rails-su-tabelle-mirate/190355 "2010-06-18T12:06:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![punkaruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/49beb7/32.png) [@punkaruby](https://www.ruby-forum.com/u/punkaruby)\
**Post date:** [June 18, 2010, 12:06pm UTC](https://www.ruby-forum.com/t/una-semplice-ricerca-in-rails-su-tabelle-mirate/190355/1 "2010-06-18T12:06:12Z")

</div>

Ciao a tutti,  
evo sviluppare una semplice funzione di ricerca mirata su un pezzo della  
mia applicazione

1- il form in app/views/layouts/teachers.html.erb

\<% form\_tag({:controller =\> “teachers”, :action =\> “search”}, :method =\>  
“get”) do %\>  
\<%= text\_field\_tag :query, nil, :id =\> “search-text” %\>  
\<%= submit\_tag(“GO”, :id =\> “search-submit”) %\>  
\<% end %\>

2- il metodo di ricerca in teacher\_controller.rb

def search  
session[:query] = params[:query].strip if params[:query]

```
if session[:query]
  @teachers = Teacher.find(:all, :conditions => ["materie LIKE ?",

```

“%#{session[:query]}%”], :order =\> “cognome ASC”)  
end  
end

3- la pagina per visualizzare i risultati in  
app/view/teachers/search.html.erb

## Docenti Trovati
  
\<% if searchresults.length == 0 %\> 

Nessun docente trovato...

\<% elsif params[:query] == "" %\> 

Inserisci una materia per cortesia.

\<% else %\>
\<% for teacher in searchresults %\> - \<%= link\_to teacher.cognome , teacher\_url(:id =\> teacher.id)%\>
\<% end %\>
\<% end %\>

Ma quando avvio la ricerca il browser si posiziona sulla pagina di  
teachers/show  
credo che manchi qualcosa in routes ma non so…

Grazie in anticipo a tutti quelli che perderanno un po’ di tempo a  
leggere e rispondere

Ciaoo

---

<div class="post-metadata">

**Author:** ![punkaruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/49beb7/32.png) [@punkaruby](https://www.ruby-forum.com/u/punkaruby)\
**Post date:** [June 18, 2010, 12:09pm UTC](https://www.ruby-forum.com/t/una-semplice-ricerca-in-rails-su-tabelle-mirate/190355/2 "2010-06-18T12:09:24Z")

</div>

Dimenticavo…il messaggio di errore

ActiveRecord::RecordNotFound in TeachersController#show

Couldn’t find Teacher with ID=search

RAILS\_ROOT: F:/rubyProjects/fg  
Application Trace | Framework Trace | Full Trace

C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active\_record/base.rb:1616:in  
`find_one' C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:1599:in `find\_from\_ids’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active\_record/base.rb:619:in  
`find' F:/rubyProjects/fg/app/controllers/teachers_controller.rb:16:in `show’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/base.rb:1331:in  
`perform_action' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/filters.rb:617:in `call\_filters’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/filters.rb:610:in  
`perform_action_with_filters' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:68:in `block in perform\_action\_with\_benchmark’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activesupport-2.3.8/lib/active\_support/core\_ext/benchmark.rb:17:in  
`block in ms' C:/Ruby191/lib/ruby/1.9.1/benchmark.rb:309:in `realtime’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activesupport-2.3.8/lib/active\_support/core\_ext/benchmark.rb:17:in  
`ms' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:68:in `perform\_action\_with\_benchmark’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/rescue.rb:160:in  
`perform_action_with_rescue' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/flash.rb:151:in `perform\_action\_with\_flash’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/base.rb:532:in  
`process' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/filters.rb:606:in `process\_with\_filters’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/base.rb:391:in  
`process' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:386:in `call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/routing/route\_set.rb:438:in  
`call’

C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active\_record/base.rb:1616:in  
`find_one' C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:1599:in `find\_from\_ids’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active\_record/base.rb:619:in  
`find' F:/rubyProjects/fg/app/controllers/teachers_controller.rb:16:in `show’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/base.rb:1331:in  
`perform_action' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/filters.rb:617:in `call\_filters’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/filters.rb:610:in  
`perform_action_with_filters' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:68:in `block in perform\_action\_with\_benchmark’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activesupport-2.3.8/lib/active\_support/core\_ext/benchmark.rb:17:in  
`block in ms' C:/Ruby191/lib/ruby/1.9.1/benchmark.rb:309:in `realtime’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activesupport-2.3.8/lib/active\_support/core\_ext/benchmark.rb:17:in  
`ms' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:68:in `perform\_action\_with\_benchmark’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/rescue.rb:160:in  
`perform_action_with_rescue' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/flash.rb:151:in `perform\_action\_with\_flash’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/base.rb:532:in  
`process' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/filters.rb:606:in `process\_with\_filters’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/base.rb:391:in  
`process' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:386:in `call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/routing/route\_set.rb:438:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:87:in `dispatch’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/dispatcher.rb:121:in  
`_call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:130:in `block in build\_middleware\_stack’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active\_record/query\_cache.rb:29:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/query_cache.rb:29:in `block in call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active\_record/connection\_adapters/abstract/query\_cache.rb:34:in  
`cache' C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/query_cache.rb:9:in `cache’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active\_record/query\_cache.rb:28:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/string\_coercion.rb:25:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/head.rb:9:in `call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/methodoverride.rb:24:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/params_parser.rb:15:in `call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/session/cookie\_store.rb:99:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/failsafe.rb:26:in `call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/lock.rb:11:in  
`block in call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/lock.rb:11:in `call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/dispatcher.rb:114:in  
`block in call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/reloader.rb:34:in `run’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/dispatcher.rb:108:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/rails-2.3.8/lib/rails/rack/static.rb:31:in `call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/urlmap.rb:47:in  
`block in call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/urlmap.rb:41:in `each’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/urlmap.rb:41:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/rails-2.3.8/lib/rails/rack/log_tailer.rb:17:in `call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/content\_length.rb:13:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/handler/webrick.rb:48:in `service’  
C:/Ruby191/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service' C:/Ruby191/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run’  
C:/Ruby191/lib/ruby/1.9.1/webrick/server.rb:183:in `block in  
start\_thread’

C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active\_record/base.rb:1616:in  
`find_one' C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:1599:in `find\_from\_ids’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active\_record/base.rb:619:in  
`find' F:/rubyProjects/fg/app/controllers/teachers_controller.rb:16:in `show’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/base.rb:1331:in  
`perform_action' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/filters.rb:617:in `call\_filters’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/filters.rb:610:in  
`perform_action_with_filters' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:68:in `block in perform\_action\_with\_benchmark’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activesupport-2.3.8/lib/active\_support/core\_ext/benchmark.rb:17:in  
`block in ms' C:/Ruby191/lib/ruby/1.9.1/benchmark.rb:309:in `realtime’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activesupport-2.3.8/lib/active\_support/core\_ext/benchmark.rb:17:in  
`ms' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:68:in `perform\_action\_with\_benchmark’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/rescue.rb:160:in  
`perform_action_with_rescue' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/flash.rb:151:in `perform\_action\_with\_flash’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/base.rb:532:in  
`process' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/filters.rb:606:in `process\_with\_filters’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/base.rb:391:in  
`process' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:386:in `call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/routing/route\_set.rb:438:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:87:in `dispatch’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/dispatcher.rb:121:in  
`_call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:130:in `block in build\_middleware\_stack’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active\_record/query\_cache.rb:29:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/query_cache.rb:29:in `block in call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active\_record/connection\_adapters/abstract/query\_cache.rb:34:in  
`cache' C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/query_cache.rb:9:in `cache’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active\_record/query\_cache.rb:28:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/string\_coercion.rb:25:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/head.rb:9:in `call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/methodoverride.rb:24:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/params_parser.rb:15:in `call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/session/cookie\_store.rb:99:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/failsafe.rb:26:in `call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/lock.rb:11:in  
`block in call' <internal:prelude>:8:in `synchronize’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/lock.rb:11:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:114:in `block in call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action\_controller/reloader.rb:34:in  
`run' C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:108:in `call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/rails-2.3.8/lib/rails/rack/static.rb:31:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/urlmap.rb:47:in `block in call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/urlmap.rb:41:in  
`each' C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/urlmap.rb:41:in `call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/rails-2.3.8/lib/rails/rack/log\_tailer.rb:17:in  
`call' C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/content_length.rb:13:in `call’  
C:/Ruby191/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/handler/webrick.rb:48:in  
`service' C:/Ruby191/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service’  
C:/Ruby191/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run' C:/Ruby191/lib/ruby/1.9.1/webrick/server.rb:183:in `block in  
start\_thread’

Request

Parameters:

{“query”=\>“scudo”,  
“commit”=\>“VAI”,  
“id”=\>“search”}

An Car wrote:

> Ciao a tutti,  
> evo sviluppare una semplice funzione di ricerca mirata su un pezzo della  
> mia applicazione
> 
> 1- il form in app/views/layouts/teachers.html.erb
> 
> \<% form\_tag({:controller =\> “teachers”, :action =\> “search”}, :method =\>  
> “get”) do %\>  
> \<%= text\_field\_tag :query, nil, :id =\> “search-text” %\>  
> \<%= submit\_tag(“GO”, :id =\> “search-submit”) %\>  
> \<% end %\>
> 
> 2- il metodo di ricerca in teacher\_controller.rb
> 
> def search  
> session[:query] = params[:query].strip if params[:query]
> 
> ```
> if session[:query]
> @teachers = Teacher.find(:all, :conditions => ["materie LIKE ?",
> 
> ```
> 
> “%#{session[:query]}%”], :order =\> “cognome ASC”)  
> end  
> end
> 
> 3- la pagina per visualizzare i risultati in  
> app/view/teachers/search.html.erb
> 
> ## Docenti Trovati
>   
> \<% if searchresults.length == 0 %\> 
> 
> Nessun docente trovato...
> 
> \<% elsif params[:query] == "" %\> 
> 
> Inserisci una materia per cortesia.
> 
> \<% else %\>
> \<% for teacher in searchresults %\> - \<%= link\_to teacher.cognome , teacher\_url(:id =\> teacher.id)%\>
> \<% end %\>
> \<% end %\>
> 
> Ma quando avvio la ricerca il browser si posiziona sulla pagina di  
> teachers/show  
> credo che manchi qualcosa in routes ma non so…
> 
> Grazie in anticipo a tutti quelli che perderanno un po’ di tempo a  
> leggere e rispondere
> 
> Ciaoo

---

<div class="post-metadata">

**Author:** ![punkaruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/49beb7/32.png) [@punkaruby](https://www.ruby-forum.com/u/punkaruby)\
**Post date:** [June 23, 2010, 3:43pm UTC](https://www.ruby-forum.com/t/una-semplice-ricerca-in-rails-su-tabelle-mirate/190355/3 "2010-06-23T15:43:12Z")

</div>

Luca, grazie !

vado subito a provare la tua soluzione

Luca G. wrote:

> C’ï¿½ una collisione di routes:  
> GET /teachers/123  
> GET /teachers/search
> 
> Per la tua applicazione non c’ï¿½ differenza, considera “search” come un id  
> (params[:id]) e non come una action del tuo controller. Per risolvere:
> 
> # config/routes.rb
> 
> map.resources :teachers, :collection =\> { :search =\> :get }
> 
> [http://guides.rails.info/routing.html](http://guides.rails.info/routing.html)
> 
> Luca

---

<div class="post-metadata">

**Author:** ![punkaruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/49beb7/32.png) [@punkaruby](https://www.ruby-forum.com/u/punkaruby)\
**Post date:** [June 19, 2010, 12:11pm UTC](https://www.ruby-forum.com/t/una-semplice-ricerca-in-rails-su-tabelle-mirate/190355/4 "2010-06-19T12:11:32Z")

</div>

C’è una collisione di routes:  
GET /teachers/123  
GET /teachers/search

Per la tua applicazione non c’è differenza, considera “search” come un id  
(params[:id]) e non come una action del tuo controller. Per risolvere:

# config/routes.rb

map.resources :teachers, :collection =\> { :search =\> :get }

[http://guides.rails.info/routing.html](http://guides.rails.info/routing.html)

Luca

---

<div class="post-metadata">

**Author:** ![punkaruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/49beb7/32.png) [@punkaruby](https://www.ruby-forum.com/u/punkaruby)\
**Post date:** [June 24, 2010, 2:12pm UTC](https://www.ruby-forum.com/t/una-semplice-ricerca-in-rails-su-tabelle-mirate/190355/5 "2010-06-24T14:12:48Z")

</div>

Funzionaaaaa !!!

Grazie ! Grazie ! Grazie !

An Car wrote:

> Luca, grazie !
> 
> vado subito a provare la tua soluzione
> 
> Luca G. wrote:
> 
> > C’ï¿½ una collisione di routes:  
> > GET /teachers/123  
> > GET /teachers/search
> > 
> > Per la tua applicazione non c’ï¿½ differenza, considera “search” come un id  
> > (params[:id]) e non come una action del tuo controller. Per risolvere:
> > 
> > # config/routes.rb
> > 
> > map.resources :teachers, :collection =\> { :search =\> :get }
> > 
> > [http://guides.rails.info/routing.html](http://guides.rails.info/routing.html)
> > 
> > Luca
