Forum: Italian Ruby user group errore con il passaggio di parametri

Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-30 13:17
Salve a tutti vorrei
il mio problema e' questo mi occorre passare tramite un link inserito
nella view index alla visualizzazione della form gruppo_utenti
pertanto nella view index inserisco questo codice
<td width="12%"><%= link_to 'Chiamate'
,user_path('gruppo_utenti'),:method => 'gruppo_utenti' %></td>

nel controller user
def gruppo_utenti
 @posts = Post.find(:all, params[:user_id]
end

nella view gruppo_utenti
chiaramente itero il ciclo per visualizzare i dati
<% for post in @posts  %>
  <table>
    <tr>
      <td>
        <%= post.id %>
      </td>
    </tr>
  </table>
<% end %>
ma mi fa visualizzare l'intero archivio senza aver effettuato nessun
filtro

mi potreste dare una mano

Grazio
fdibenedetto
Posted by Luigi Maselli - grigio.org (grigio)
on 2010-08-30 14:53
Fabio Di benedetto wrote:
> ...  :method => 'gruppo_utenti' ?????

hai provato a dare un'occhiata alla guida ufficiale?
http://guides.rubyonrails.org/routing.html

Quel :method, potrebbe essere :action, ma dipende come hai impostato il 
file routes.rb
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-30 15:17
Luigi Maselli - grigio.org wrote:
> Fabio Di benedetto wrote:
>> ...  :method => 'gruppo_utenti' ?????
> 
> hai provato a dare un'occhiata alla guida ufficiale?
> http://guides.rubyonrails.org/routing.html
> 
> Quel :method, potrebbe essere :action, ma dipende come hai impostato il 
> file routes.rb
Ciao Luigi,
allora il file di route e' impostato
  map.resources :users
  map.resources :groups
  map.resources :phones
  map.resources :purchases
  map.resources :posts
  map.resources :utentis
  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'

inoltre se sostituisco il :method con :action mi sposta sulla view show 
dandomi giustamente l'errore
penso che l'errore sia nel file di route ma dove ???
a me sembra corretto!
Saluti

fdibenedetto
Posted by Antonio Cangiano (Guest)
on 2010-08-30 15:18
(Received via mailing list)
2010/8/30 Fabio Di benedetto <f_dibenedetto72@hotmail.com>

> il mio problema e' questo mi occorre passare tramite un link inserito
> nella view index alla visualizzazione della form gruppo_utenti
> pertanto nella view index inserisco questo codice
> <td width="12%"><%= link_to 'Chiamate'
> ,user_path('gruppo_utenti'),:method => 'gruppo_utenti' %></td>
>

Fai un bel rake routes per vedere se hai una named route 
gruppo_utenti_users
(in generale, meglio evitare i nomi italiani nel codice come vedi).

Se sì, puoi usare semplicemente:

<%= link_to 'Chiamate', gruppo_utenti_users_path %>

:metod serve solo per specificare il tipo di verbo HTTP se non si tratta 
di
un semplice GET (e nel tuo caso è un GET).

Se non hai gruppo_utenti_users nell'output di rake routes, vuole dire 
che
non hai definito la route in routes.rb. Puoi farlo aggiungendo l'action 
alla
risorsa:

resources :users do
  collection do
    get :gruppo_utenti
  end
end

Se non usi Rails 3, puoi sempre scriverlo nel vecchio modo:

map.resources :users, :collection => { :gruppo_utenti => :get }

Ciao,
Antonio
--
Homepage: http://antoniocangiano.com
High-Quality Programming Screencasts: http://thinkcode.tv
Any new books? Get weekly updates by email: http://anynewbooks.com/
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-30 16:13
Antonio Cangiano wrote:
> 2010/8/30 Fabio Di benedetto <f_dibenedetto72@hotmail.com>
> 
>> il mio problema e' questo mi occorre passare tramite un link inserito
>> nella view index alla visualizzazione della form gruppo_utenti
>> pertanto nella view index inserisco questo codice
>> <td width="12%"><%= link_to 'Chiamate'
>> ,user_path('gruppo_utenti'),:method => 'gruppo_utenti' %></td>
>>
> 
> Fai un bel rake routes per vedere se hai una named route 
> gruppo_utenti_users
> (in generale, meglio evitare i nomi italiani nel codice come vedi).
> 
> Se s�, puoi usare semplicemente:
> 
> <%= link_to 'Chiamate', gruppo_utenti_users_path %>
> 
> :metod serve solo per specificare il tipo di verbo HTTP se non si tratta 
> di
> un semplice GET (e nel tuo caso � un GET).
> 
> Se non hai gruppo_utenti_users nell'output di rake routes, vuole dire 
> che
> non hai definito la route in routes.rb. Puoi farlo aggiungendo l'action 
> alla
> risorsa:
> 
> resources :users do
>   collection do
>     get :gruppo_utenti
>   end
> end
> 
> Se non usi Rails 3, puoi sempre scriverlo nel vecchio modo:
> 
> map.resources :users, :collection => { :gruppo_utenti => :get }
> 
> Ciao,
> Antonio
> --
> Homepage: http://antoniocangiano.com
> High-Quality Programming Screencasts: http://thinkcode.tv
> Any new books? Get weekly updates by email: http://anynewbooks.com/

Antonio Scusa ancora,
ho inserito nel file di routes
map.resources :users, :collection => { :gruppo_utenti => :get }
ma mi punta sempre allo show
inoltre ho visto con il rake che la rotta esiste
gruppo_utenti_users GET    /users/gruppo_utenti(.:format) 
{:controller=>"use
rs", :action=>"gruppo_utenti"}
ma mi chiedo dove sta l'errore ?
Saluti
fdibenedetto
Posted by Antonio Cangiano (Guest)
on 2010-08-30 16:17
(Received via mailing list)
2010/8/30 Fabio Di benedetto <f_dibenedetto72@hotmail.com>

>  inoltre ho visto con il rake che la rotta esiste
> gruppo_utenti_users GET    /users/gruppo_utenti(.:format)
> {:controller=>"use
> rs", :action=>"gruppo_utenti"}
>

Bene.


> ma mi chiedo dove sta l'errore ?
>

Hai già fatto il restart del server? (È necessario quando si modifica
routes.rb.)

--
Homepage: http://antoniocangiano.com
High-Quality Programming Screencasts: http://thinkcode.tv
Any new books? Get weekly updates by email: http://anynewbooks.com/
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-30 16:24
Antonio Cangiano wrote:
> 2010/8/30 Fabio Di benedetto <f_dibenedetto72@hotmail.com>
> 
>>  inoltre ho visto con il rake che la rotta esiste
>> gruppo_utenti_users GET    /users/gruppo_utenti(.:format)
>> {:controller=>"use
>> rs", :action=>"gruppo_utenti"}
>>
> 
> Bene.
> 
> 
>> ma mi chiedo dove sta l'errore ?
>>
> 
> Hai gi� fatto il restart del server? (� necessario quando si modifica
> routes.rb.)
> 
> --
> Homepage: http://antoniocangiano.com
> High-Quality Programming Screencasts: http://thinkcode.tv
> Any new books? Get weekly updates by email: http://anynewbooks.com/

si ma per ulteriore conferma restarto ora !
inoltre nella index ho inserito
<td width="12%"><%= link_to 'Chiamate' ,gruppo_utenti_users_path(user) , 
:method=>'get' %></td>
ora l'errore e'
ed all'indirizzo 
http://localhost:3000/users/gruppo_utenti.#<user:0x3409340>
credo che l'array lo stia passando

saluti Fdibenedetto
Routing Error
No route matches "/users/gruppo_utenti." with {:method=>:get}

Posted by Antonio Cangiano (Guest)
on 2010-08-30 16:43
(Received via mailing list)
2010/8/30 Fabio Di benedetto <f_dibenedetto72@hotmail.com>

> inoltre nella index ho inserito
> <td width="12%"><%= link_to 'Chiamate' ,gruppo_utenti_users_path(user) ,
> :method=>'get' %></td>
>

L'action gruppo_utenti l'hai definita come collection, non come member, 
per
cui non puoi passargli un parametro.

Confesso di aver letto di corsa il tuo messaggio iniziale per cui non mi 
era
chiarissimo cosa intendessi fare, ma dato questo tuo tentativo qui 
sopra, mi
pare chiaro che tu voglia in realtà un metodo membro della risorsa a cui
passare un parametro. Sì tratta in pratica di uno show filtrato (hai una
collection di posts, ma vuoi comunque accedere a un particolare elemento
della risorsa users). In tal caso devi usare un altro approccio.

In routes.rb:

map.resources :users, :member => { :gruppo_utenti => :get }

Nel link:

<%= link_to 'Chiamate', gruppo_utenti_user_path(user) %>

Avrai inoltre bisogno di un file app/views/users/gruppo_utenti.html.erb.


Ciao,
Antonio
--
Homepage: http://antoniocangiano.com
High-Quality Programming Screencasts: http://thinkcode.tv
Any new books? Get weekly updates by email: http://anynewbooks.com/
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-30 17:50
Antonio Cangiano wrote:
> 2010/8/30 Fabio Di benedetto <f_dibenedetto72@hotmail.com>
> 
>> inoltre nella index ho inserito

Ok Antonio Funziona perfettamente
solo che non riesco a trovare informazioni utili sulla configurazione di
route in italiano oppure qualch'uno in grado di spiegarmelo !
Saluti
fdibenedetto
Posted by Antonio Cangiano (Guest)
on 2010-08-30 19:43
(Received via mailing list)
2010/8/30 Fabio Di benedetto <f_dibenedetto72@hotmail.com>

> Ok Antonio Funziona perfettamente
>

Ottimo.


> solo che non riesco a trovare informazioni utili sulla configurazione di
> route in italiano oppure qualch'uno in grado di spiegarmelo !
>

Purtroppo in italiano c'è ben poco. Suggerirei di fare uno sforzo per
imparare dalla documentazione in inglese. Se hai domande specifiche, 
chiedi
pure qui.
--
Homepage: http://antoniocangiano.com
High-Quality Programming Screencasts: http://thinkcode.tv
Any new books? Get weekly updates by email: http://anynewbooks.com/
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-31 12:28
ciao Antonio
ho un quesito da porti !
nella vista index ho questa linea
<td with="5%"><%=h Phone.find_by_user_id(user.id).to_s.split%></td>
funziona perfettamente mi restituisce chiaramente l'intero array
ma se io volessi ricevere solamente un campo dell'intera tabella ?
come devo fare ?

Saluti,
Fdibenedetto
Posted by Antonio Cangiano (Guest)
on 2010-08-31 13:23
(Received via mailing list)
2010/8/31 Fabio Di benedetto <f_dibenedetto72@hotmail.com>

> nella vista index ho questa linea
> <td with="5%"><%=h Phone.find_by_user_id(user.id).to_s.split%></td>
> funziona perfettamente mi restituisce chiaramente l'intero array
> ma se io volessi ricevere solamente un campo dell'intera tabella ?
>

In generale ti consiglio di mettere chiamate di questo tipo (find)
all'interno del controller e non direttamente nelle view. Puoi 
assegnarle a
una variabile d'istanza e poi usare quella variable nella view.

In ogni caso, se hai un'associazione tra Phone e User, non hai bisogno 
di
fare find_by_user_id, puoi semplicemente usare user.phone (o user.phones 
se
è 1-to-many, ma in tal caso ti restituisce un array).

Per accedere a un campo specifico (assumendo una relazione 1-to-1 tra 
Phone
e User) puoi fare:

user.phone.my_field

Dove my_field è l'attributo del modello Phone che ti interessa.

Se l'associazione che hai dichiarato è 1-to-many, puoi ottenere il valore 
di
my_field per il primo numero di telefono associato con un dato user, in
questo modo:

user.phones.first.my_field

user.phones ti restituisce un array di oggetti Phone associati 
all'utente
user (istanza di User). Con first ottieni il primo.


Ciao,
Antonio
--
Homepage: http://antoniocangiano.com
High-Quality Programming Screencasts: http://thinkcode.tv
Receive weekly updates about new books covering the subjects you love:
http://anynewbooks.com
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-31 15:24
Antonio Cangiano wrote:
> 2010/8/31 Fabio Di benedetto <f_dibenedetto72@hotmail.com>
> 
>> nella vista index ho questa linea
>> <td with="5%"><%=h Phone.find_by_user_id(user.id).to_s.split%></td>
>> funziona perfettamente mi restituisce chiaramente l'intero array
>> ma se io volessi ricevere solamente un campo dell'intera tabella ?
>>
> 
> In generale ti consiglio di mettere chiamate di questo tipo (find)
> all'interno del controller e non direttamente nelle view. Puoi 
> assegnarle a
> una variabile d'istanza e poi usare quella variable nella view.
> 
> In ogni caso, se hai un'associazione tra Phone e User, non hai bisogno 
> di
> fare find_by_user_id, puoi semplicemente usare user.phone (o user.phones 
> se
> � 1-to-many, ma in tal caso ti restituisce un array).
> 
> Per accedere a un campo specifico (assumendo una relazione 1-to-1 tra 
> Phone
> e User) puoi fare:
> 
> user.phone.my_field

> 
> Dove my_field � l'attributo del modello Phone che ti interessa.
> 
> Se l'associazione che hai dichiarato � 1-to-many, puoi ottenere il valore 
> di
> my_field per il primo numero di telefono associato con un dato user, in
> questo modo:
> 
> user.phones.first.my_field
> 
> user.phones ti restituisce un array di oggetti Phone associati 
> all'utente
> user (istanza di User). Con first ottieni il primo.
> 
Ciao Antonio ,
La relazione ed di 1 a molti semmai pensavo di deinire nel controller 
una def di questo tipo
def ricerca_phone(user_id)
      @phone=Phone.find(:first, conditions=>["user_id=? and phonetype=1" 
,user_id ])
      if @phone.nil?
        @ricerca_phone=phone.number
      else
        @ricerca_phone=1
      end
end
nella view chiaramente inserirei
td with="5%"><%=h ricerca_phone(user.id).to_s.split%></td>
Saluti Fabio
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-31 16:29
Antonio scusa se ti disturbo ancora ma mi occorre risolvere questo 
problema
allora nell' application_controller ho ridefinito la funzione

def self.searchphone(user)
      @searchphones= find(:first, conditions=>["user_id=? and 
phonetype=1",user[:id]])
      @searchphones.each do |p|
        @searchphone = p.number
      end
    end

nella view ho inserito

<td with="5%"><%  Phone.searcphone(user) %></td>
ma mi da l'errore:
undefined method `searcphone' for #<Class:0x3823640>
ma dove commetto l'errore mi potresti dare aiuto?
grazie
fdibenedetto
Posted by Paolo Perego (Guest)
on 2010-08-31 16:32
(Received via mailing list)
Hai un typo quando richiami il metodo.
Lo hai definito come self.searchphone e lo richiami come
Phone.searcphone, manca l'h in search.

Ciao ciao
Paolo

2010/8/31 Fabio Di benedetto <f_dibenedetto72@hotmail.com>:
>    end
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Ml mailing list
> Ml@lists.ruby-it.org
> http://lists.ruby-it.org/mailman/listinfo/ml
>



--
"... static analysis is fun, again!"

OWASP Orizon project leader, http://github.com/owasp-orizon
Owasp Italy R&D director
Posted by Pietro Giorgianni (giorgian)
on 2010-08-31 16:42
(Received via mailing list)
Il 31 agosto 2010 16:29, Fabio Di benedetto
<f_dibenedetto72@hotmail.com> ha scritto:
>    end
Ciao,

a parte il typo che ti hanno già segnalato, nota che stai assegnando
ogni volta p.number a @searchphone, per cui alla fine @searchphone
varrà l'ultimo p.number incontrato, e non credo sia quello che vuoi.


pietro
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-31 16:50
Ciao Paolo
la view l'ho corretta in :
td with="5%"><%  searchphone(user) %></td>

ho corretto anche il controller nel modo seguente

    def searchphone(user)
        @searchphones= Phone.find(:first, conditions=>["user_id=? and 
phonetype=1",user[:id]])
        @searchphones.each do |p|
          @searchphone = p.number
      end
    end

Ma ancora mi visualizza l'errore:
NoMethodError in Users#index
Showing app/views/users/index.html.erb where line #58 raised:

undefined method `searchphone' for #<ActionView::Base:0x2c5f120>

Extracted source (around line #58):

55:             <td width="5%"><%=h user.username %></td>
56:             <td width="5%"><%=h user.password %></td>
57:             <td width="5%"><%= 
Phone.find_by_user_id(user.id).to_s.split%></td>
58:             <td with="5%"><%  searchphone(user) %></td>

RAILS_ROOT: C:/testapp

Application Trace | Framework Trace | Full Trace
C:/testapp/app/views/users/index.html.erb:58:in `block in 
_run_erb_app47views47users47index46html46erb'
C:/testapp/app/views/users/index.html.erb:50:in `each'
C:/testapp/app/views/users/index.html.erb:50:in 
`_run_erb_app47views47users47index46html46erb'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/renderable.rb:34:in 
`block in render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/base.rb:306:in 
`with_template'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/renderable.rb:30:in 
`render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/template.rb:205:in 
`render_template'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/base.rb:265:in 
`render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/base.rb:348:in 
`_render_with_layout'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/base.rb:262:in 
`render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:1250:in 
`render_for_file'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:936:in 
`render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:51:in 
`block in render_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:51:in 
`render_with_benchmark'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:1326:in 
`default_render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:1332: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:/testapp/app/views/users/index.html.erb:58:in `block in 
_run_erb_app47views47users47index46html46erb'
C:/testapp/app/views/users/index.html.erb:50:in `each'
C:/testapp/app/views/users/index.html.erb:50:in 
`_run_erb_app47views47users47index46html46erb'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/renderable.rb:34:in 
`block in render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/base.rb:306:in 
`with_template'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/renderable.rb:30:in 
`render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/template.rb:205:in 
`render_template'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/base.rb:265:in 
`render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/base.rb:348:in 
`_render_with_layout'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/base.rb:262:in 
`render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:1250:in 
`render_for_file'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:936:in 
`render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:51:in 
`block in render_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:51:in 
`render_with_benchmark'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:1326:in 
`default_render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:1332: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:

None

Show session dump

---

Response
Headers:

{"Cache-Control"=>"no-cache",
 "Content-Type"=>"text/html"}



Paolo Perego wrote:
> Hai un typo quando richiami il metodo.
> Lo hai definito come self.searchphone e lo richiami come
> Phone.searcphone, manca l'h in search.
> 
> Ciao ciao
> Paolo
> 
> 2010/8/31 Fabio Di benedetto <f_dibenedetto72@hotmail.com>:
>> � �end
>> Posted via http://www.ruby-forum.com/.
>> _______________________________________________
>> Ml mailing list
>> Ml@lists.ruby-it.org
>> http://lists.ruby-it.org/mailman/listinfo/ml
>>
> 
> 
> 
> --
> "... static analysis is fun, again!"
> 
> OWASP Orizon project leader, http://github.com/owasp-orizon
> Owasp Italy R&D director
Posted by Antonio Cangiano (Guest)
on 2010-08-31 17:13
(Received via mailing list)
2010/8/31 Fabio Di benedetto <f_dibenedetto72@hotmail.com>

> allora nell' application_controller ho ridefinito la funzione
>
> def self.searchphone(user)
>      @searchphones= find(:first, conditions=>["user_id=? and
> phonetype=1",user[:id]])
>      @searchphones.each do |p|
>        @searchphone = p.number
>      end
>    end
>

Fabio, ti suggerirei di leggere un tutorial, perché secondo me ti mancano 
un
po' le basi ora come ora. Ci sono molti problemi col codice qui sopra.

Potresti usare il seguente scenario.

# Controller
def my_action
  user = ...
  @phones = user.phone.find_all_by_phonetype(1)
end

# View
<% @phones.each do |phone| %>
    <%=h phone.number %>
<% end -%>

Ciao,
Antonio
--
Homepage: http://antoniocangiano.com
High-Quality Programming Screencasts: http://thinkcode.tv
Receive weekly updates about new books covering the subjects you love:
http://anynewbooks.com
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-31 17:41
Antonio Cangiano wrote:
> 2010/8/31 Fabio Di benedetto <f_dibenedetto72@hotmail.com>
> 
>> allora nell' application_controller ho ridefinito la funzione
>>
>> def self.searchphone(user)
>>      @searchphones= find(:first, conditions=>["user_id=? and
>> phonetype=1",user[:id]])
>>      @searchphones.each do |p|
>>        @searchphone = p.number
>>      end
>>    end
>>
> 
> Fabio, ti suggerirei di leggere un tutorial, perch� secondo me ti mancano 
> un
> po' le basi ora come ora. Ci sono molti problemi col codice qui sopra.
> 
> Potresti usare il seguente scenario.
> 
> # Controller
> def my_action
>   user = ...
>   @phones = user.phone.find_all_by_phonetype(1)
> end
> 
> # View
> <% @phones.each do |phone| %>
>     <%=h phone.number %>
> <% end -%>
> 
> Ciao,
> Antonio
> --
Antonio scusa ancora ma se nel def faccio questo tipo di selezione avro 
tutti i numeri con type.. =1 semmai a me serve user_id ?  and 
typephone=1 ecco perche metto il codice anche nella view perche dal 
ciclo della view ricevo l'id da passare alla def per ricevere il number
Grazie Sempre
Fdibenedetto
Posted by Pietro Giorgianni (giorgian)
on 2010-08-31 17:48
(Received via mailing list)
Il 31 agosto 2010 17:41, Fabio Di benedetto
<f_dibenedetto72@hotmail.com> ha scritto:
> Antonio Cangiano wrote:
>> # Controller
>> def my_action
>>   user = ...
>>   @phones = user.phone.find_all_by_phonetype(1)

qui credo ci sia un typo, probabilmente dovrebbe essere
@phones = user.phones.find_all_by_phonetype(1)

> Antonio scusa ancora ma se nel def faccio questo tipo di selezione avro
> tutti i numeri con type.. =1 semmai a me serve user_id ?  and
> typephone=1

Se hai un'associazione uno a molti in cui un user ha molti phone, 
scrivere:
@phones = user.phones.find_all_by_phonetype(1)

è equivalente a scrivere:
@phones = Phone.find :all, :conditions => {:user_id => user.id, 
:phonetype => 1}

Ad alcun* i metodi find_by_qualcosa non piacciono, altri li adorano,
sono gusti; usare l'associazione anziché passare l'id esplicitamente
mi sembra invece oggettivamente molto più leggibile - anche se poi è 
più o meno la stessa cosa, l'SQL generato non cambia...


pietro
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-31 18:05
Pietro Giorgianni wrote:
> Il 31 agosto 2010 17:41, Fabio Di benedetto
> <f_dibenedetto72@hotmail.com> ha scritto:
>> Antonio Cangiano wrote:
>>> # Controller
>>> def my_action
>>> � user = ...
>>> � @phones = user.phone.find_all_by_phonetype(1)
> 
> qui credo ci sia un typo, probabilmente dovrebbe essere
> @phones = user.phones.find_all_by_phonetype(1)
> 
>> Antonio scusa ancora ma se nel def faccio questo tipo di selezione avro
>> tutti i numeri con type.. =1 semmai a me serve user_id ? �and
>> typephone=1
> 
> Se hai un'associazione uno a molti in cui un user ha molti phone, 
> scrivere:
> @phones = user.phones.find_all_by_phonetype(1)
> 
> � equivalente a scrivere:
> @phones = Phone.find :all, :conditions => {:user_id => user.id, 
> :phonetype => 1}
> 
> Ad alcun* i metodi find_by_qualcosa non piacciono, altri li adorano,
> sono gusti; usare l'associazione anzich� passare l'id esplicitamente
> mi sembra invece oggettivamente molto pi� leggibile - anche se poi � 
pi� o meno la stessa cosa, l'SQL generato non cambia...
> 
> 
> pietro
ciao Pietro grazie per la delucidazione e mi scuso con antonio se ho 
ribbadito il concetto di antonio !!
venendo al problema ed inserendo nella view il seguente codice
<td with="5%"><%=h user.phones.find_all_by_typephone_id(1)  %></td>
riesco a vedere l'intero array ma a me serve prendere solo un campo sto 
benedetto number !!!
fdibenedetto
Posted by Antonio Cangiano (Guest)
on 2010-08-31 18:13
(Received via mailing list)
2010/8/31 Pietro Giorgianni <giorgian@gmail.com>

> qui credo ci sia un typo, probabilmente dovrebbe essere
> @phones = user.phones.find_all_by_phonetype(1
> )
> )
>

Sì, typo.
--
Homepage: http://antoniocangiano.com
High-Quality Programming Screencasts: http://thinkcode.tv
Receive weekly updates about new books covering the subjects you love:
http://anynewbooks.com
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-31 18:38
Antonio Cangiano wrote:
> 2010/8/31 Pietro Giorgianni <giorgian@gmail.com>
> 
>> qui credo ci sia un typo, probabilmente dovrebbe essere
>> @phones = user.phones.find_all_by_phonetype(1
>> )
>> )
>>
> 
> S�, typo.
> --
> Homepage: http://antoniocangiano.com
> High-Quality Programming Screencasts: http://thinkcode.tv
> Receive weekly updates about new books covering the subjects you love:
> http://anynewbooks.com

mi dispiace ma non capisco e sicuramente io sono poco chiaro e molto 
inesperto in rails.
riepiloghiamo
ho una tabella users con i campi id , name
tabella phones  campi id, number , typephone_id , user_id
nei model ho dichiarato le relazioni
class User < ActiveRecord::Base
  has_many :phones
class Phone < ActiveRecord::Base
  belongs_to :user , :foreign_key =>'user_id' (questa si potrebbe 
omettere)

nella view index di user vorrei inserire tutti i campi di users ed il 
solo campo number di phones con typephones=1
quindi :
id namber        number
1  fdibenedetto   253
2  ciccillo       254
scusate veraemnte la mia poca esperienza ma a me viene piu semplice 
capire le cose con un esempio per poi studiarlo

Saluti
fdibenedetto
Posted by Antonio Cangiano (Guest)
on 2010-08-31 18:43
(Received via mailing list)
2010/8/31 Fabio Di benedetto <f_dibenedetto72@hotmail.com>

> capire le
> cose
> cose con un esempio per poi studiarlo
>

Se copi il mio esempio verbatim, a parte correggere il typo phones 
invece di
phone, dovrebbe funzionare.

Ciao,
Antonio
--
Homepage: http://antoniocangiano.com
High-Quality Programming Screencasts: http://thinkcode.tv
Receive weekly updates about new books covering the subjects you love:
http://anynewbooks.com
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-31 19:24
Antonio Cangiano wrote:
> 2010/8/31 Fabio Di benedetto <f_dibenedetto72@hotmail.com>
> 
>> capire le
>> cose
>> cose con un esempio per poi studiarlo
>>
> 
> Se copi il mio esempio verbatim, a parte correggere il typo phones 
> invece di
me lo puoi rimandare ?
scusa l'insistenza!!
Posted by Antonio Cangiano (Guest)
on 2010-08-31 19:36
(Received via mailing list)
2010/8/31 Fabio Di benedetto <f_dibenedetto72@hotmail.com>

> me lo puoi
> rimandare
> rimandare ?
>

# Controller
def my_action
  user = User.find(params[:id])
  @phones = user.phones.find_all_by_phonetype(1)
end

# View
<% @phones.each do |phone| %>
   <td><%=h phone.number %></td>
<% end -%>


Ciao,
Antonio
--
Homepage: http://antoniocangiano.com
High-Quality Programming Screencasts: http://thinkcode.tv
Receive weekly updates about new books covering the subjects you love:
http://anynewbooks.com
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-31 20:20
> # Controller
> def my_action
>   user = User.find(params[:id])
>   @phones = user.phones.find_all_by_phonetype(1)
> end
> 
> # View
> <% @phones.each do |phone| %>
>    <td><%=h phone.number %></td>
> <% end -%>
Antonio ho copiato il codice cosi come mi hai mandato
cambiando solo il nome della def numbertel nel controller user
ma mi restituisce l'errore :

NoMethodError in Users#index
Showing app/views/users/index.html.erb where line #59 raised:

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each

Extracted source (around line #59):

56:             <td width="5%"><%=h user.password %></td>
57:             <td width="5%"><%=h 
Phone.find_by_user_id(user.id).to_s.split%></td>
58:             <td with="5%"><%=h 
user.phones.find_all_by_typephone_id(1)%></td>
59: <% @phones.each do |phone| %>
60:             <td><%=h phone.number%></td>
61: <% end -%>
62:             <!--            <td width="12%">%= link_to 'Chiamate' 
,gruppo_utenti_user_path('gruppo_utenti'),:action => 'gruppo_utenti' , 
:method=>'get' %</td> -->



RAILS_ROOT: C:/testapp

Application Trace | Framework Trace | Full Trace
C:/testapp/app/views/users/index.html.erb:59:in `block in 
_run_erb_app47views47users47index46html46erb'
C:/testapp/app/views/users/index.html.erb:50:in `each'
C:/testapp/app/views/users/index.html.erb:50:in 
`_run_erb_app47views47users47index46html46erb'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/renderable.rb:34:in 
`block in render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/base.rb:306:in 
`with_template'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/renderable.rb:30:in 
`render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/template.rb:205:in 
`render_template'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/base.rb:265:in 
`render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/base.rb:348:in 
`_render_with_layout'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/base.rb:262:in 
`render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:1250:in 
`render_for_file'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:936:in 
`render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:51:in 
`block in render_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:51:in 
`render_with_benchmark'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:1326:in 
`default_render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:1332: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:/testapp/app/views/users/index.html.erb:59:in `block in 
_run_erb_app47views47users47index46html46erb'
C:/testapp/app/views/users/index.html.erb:50:in `each'
C:/testapp/app/views/users/index.html.erb:50:in 
`_run_erb_app47views47users47index46html46erb'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/renderable.rb:34:in 
`block in render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/base.rb:306:in 
`with_template'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/renderable.rb:30:in 
`render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/template.rb:205:in 
`render_template'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/base.rb:265:in 
`render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/base.rb:348:in 
`_render_with_layout'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_view/base.rb:262:in 
`render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:1250:in 
`render_for_file'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:936:in 
`render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:51:in 
`block in render_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:51:in 
`render_with_benchmark'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:1326:in 
`default_render'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/actionpack-2.3.8/lib/action_controller/base.rb:1332: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:

None

Posted by Antonio Cangiano (Guest)
on 2010-08-31 20:25
(Received via mailing list)
On Tue, Aug 31, 2010 at 2:20 PM, Fabio Di benedetto <
f_dibenedetto72@hotmail.com> wrote:

> Antonio ho copiato il codice cosi come mi hai mandato
> cambiando solo il nome della def numbertel nel controller user
> ma mi restituisce l'errore :
>
> NoMethodError in Users#index
>

Hai definito l'action numbertel nel file config/routes.rb? L'errore te 
lo
sta dando in index, quando il metodo si chiama numbertel.
--
Homepage: http://antoniocangiano.com
High-Quality Programming Screencasts: http://thinkcode.tv
Receive weekly updates about new books covering the subjects you love:
http://anynewbooks.com
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-31 20:58
Antonio Cangiano wrote:
> On Tue, Aug 31, 2010 at 2:20 PM, Fabio Di benedetto <
> f_dibenedetto72@hotmail.com> wrote:
> 
>> Antonio ho copiato il codice cosi come mi hai mandato
>> cambiando solo il nome della def numbertel nel controller user
>> ma mi restituisce l'errore :
>>
>> NoMethodError in Users#index
>>
> 
> Hai definito l'action numbertel nel file config/routes.rb? L'errore te 
> lo
> sta dando in index, quando il metodo si chiama {.
 si l'ho dichiarata come
map.resources :users , :member =>{ :numbertel => :get }
Posted by Antonio Cangiano (Guest)
on 2010-08-31 21:12
(Received via mailing list)
2010/8/31 Fabio Di benedetto <f_dibenedetto72@hotmail.com>
>  si l'ho dichiarata come
> map.resources :users , :member =>{ :numbertel => :get }

Ti sta facendo il rendering di app/views/users/index.html.erb non
di app/views/users/numbertel.html.erb. Hai creato un template
numbertel.html.erb? Se lanci rake routes vedi la route per numbertel? 
Hai
fatto il restart del server?
--
Homepage: http://antoniocangiano.com
High-Quality Programming Screencasts: http://thinkcode.tv
Receive weekly updates about new books covering the subjects you love:
http://anynewbooks.com
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-31 21:18
Antonio Cangiano wrote:
> 2010/8/31 Fabio Di benedetto <f_dibenedetto72@hotmail.com>
>>  si l'ho dichiarata come
>> map.resources :users , :member =>{ :numbertel => :get }
> 
> Ti sta facendo il rendering di app/views/users/index.html.erb non
> di app/views/users/numbertel.html.erb. Hai creato un template
> numbertel.html.erb? Se lanci rake routes vedi la route per numbertel? 
> Hai
> fatto il restart del server?
> --
> Homepage: http://antoniocangiano.com
> High-Quality Programming Screencasts: http://thinkcode.tv
> Receive weekly updates about new books covering the subjects you love:
> http://anynewbooks.com

antonio scusa ma io il numero di telefono lo devo vedere nella index
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-31 21:21
Fabio Di benedetto wrote:
> Antonio Cangiano wrote:
>> 2010/8/31 Fabio Di benedetto <f_dibenedetto72@hotmail.com>
>>>  si l'ho dichiarata come
>>> map.resources :users , :member =>{ :numbertel => :get }
>> 
>> Ti sta facendo il rendering di app/views/users/index.html.erb non
>> di app/views/users/numbertel.html.erb. Hai creato un template
>> numbertel.html.erb? Se lanci rake routes vedi la route per numbertel? 
>> Hai
>> fatto il restart del server?
>> --
>> Homepage: http://antoniocangiano.com
>> High-Quality Programming Screencasts: http://thinkcode.tv
>> Receive weekly updates about new books covering the subjects you love:
>> http://anynewbooks.com
> 
> antonio scusa ma io il numero di telefono lo devo vedere nella index

ho fatto il rake routes e c'e

numbertel_user GET    /users/:id/numbertel(.:format) 
{:controller=>"user
s", :action=>"numbertel"}
Posted by Antonio Cangiano (Guest)
on 2010-08-31 21:32
(Received via mailing list)
On Tue, Aug 31, 2010 at 3:18 PM, Fabio Di benedetto <
f_dibenedetto72@hotmail.com> wrote:
> antonio scusa ma io il numero di telefono lo
> devo vedere nella index

E allora non puoi creare una nuova action e pensare di trovare la 
variabile
di istanza dentro a index. Per quello suggerivo di seguire un tutorial o 
un
libro per farti le basi.

Comunque puoi risolvere 
così:
# Modello user
class User < ActiveRecord::Base
  ...
  ...
  def phone_numbers
    self.phones.find_all_by_phonetype(1)
  end
  ...
  ...
end

# View index.html.erb
<% @users.each do |user| %>
  <tr>
    <td><%= user.name %></td>
    ...
    ...
    ...
<% user.phone_numbers.each do |phone| %>
    <td><%=h phone.number %></td>
<% end -%>
    ...
    ...
  </tr>
<% end -%>

Rimuovi numbertel sia dalle route sia dal controller, che non ti serve.

Ciao,
Antonio
--
Homepage: http://antoniocangiano.com
High-Quality Programming Screencasts: http://thinkcode.tv
Receive weekly updates about new books covering the subjects you love:
http://anynewbooks.com
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-31 22:05
Antonio Cangiano wrote:
> On Tue, Aug 31, 2010 at 3:18 PM, Fabio Di benedetto <
> f_dibenedetto72@hotmail.com> wrote:
>> antonio scusa ma io il numero di telefono lo
>> devo vedere nella index
> 
> E allora non puoi creare una nuova action e pensare di trovare la 
> variabile
> di istanza dentro a index. Per quello suggerivo di seguire un tutorial o 
> un
> libro per farti le basi.
> 
> Comunque puoi risolvere 
> cos�:
# Modello user
> class User < ActiveRecord::Base
>   ...
>   ...
>   def phone_numbers
>     self.phones.find_all_by_phonetype(1)
>   end
>   ...
>   ...
> end
> 
> # View index.html.erb
> <% @users.each do |user| %>
>   <tr>
>     <td><%= user.name %></td>
>     ...
>     ...
>     ...
> <% user.phone_numbers.each do |phone| %>
>     <td><%=h phone.number %></td>
> <% end -%>
>     ...
>     ...
>   </tr>
> <% end -%>
> 
> Rimuovi numbertel sia dalle route sia dal controller, che non ti serve.
> 
> Ciao,

Antonio carissimo funziona grazie mille anche se io questa mattina ora 
italiana c'ero arrivato quasi

     def find_phone(user)
        self.phones.find(:all, conditions=>["user_id=? and 
phonetype_id=1",user[:id]])
    end

era nella view che avevo problemi poi mi sono del tutto perso
cmq hai ragione a ribbadirmi  dei tutorial ne ho 4 e li sto cercando di 
leggere tutti e quattro
ma un buon guru come te non guasta mai ! :-)
Grazie x la tua disponibilita e calma,con un caprone come me c'e da 
perderla subito e facilmente ma abbi pazienza io provengo da  vb6  dove 
tutto e' di una facilita disarmante. Ho detto basta con  microsoft anche 
se per tutti questi anni m'ha fatto vivere egregiamente  voglio 
approfondire su ruby on rails per riuscire a fare il porting di alcune 
applicazioni che sfruttano informix ed asterisk
Ti saluto e ti ringrazio ancora
Ti chiedo l'ultima cosa vorresti farmi un corso-online Pagato s'intende 
!!
Saluti Fabio!
Posted by fdibe nedetto (fdibenedetto72)
on 2010-09-01 15:55
Fabio Di benedetto wrote:
> Antonio Cangiano wrote:
>> On Tue, Aug 31, 2010 at 3:18 PM, Fabio Di benedetto <
>> f_dibenedetto72@hotmail.com> wrote:
>>> antonio scusa ma io il numero di telefono lo
>>> devo vedere nella index
>> 
>> E allora non puoi creare una nuova action e pensare di trovare la 
>> variabile
>> di istanza dentro a index. Per quello suggerivo di seguire un tutorial o 
>> un
>> libro per farti le basi.
>> 
>> Comunque puoi risolvere 
>> cos�:
> # Modello user
>> class User < ActiveRecord::Base
>>   ...
>>   ...
>>   def phone_numbers
>>     self.phones.find_all_by_phonetype(1)
>>   end
>>   ...
>>   ...
>> end
>> 
>> # View index.html.erb
>> <% @users.each do |user| %>
>>   <tr>
>>     <td><%= user.name %></td>
>>     ...
>>     ...
>>     ...
>> <% user.phone_numbers.each do |phone| %>
>>     <td><%=h phone.number %></td>
>> <% end -%>
>>     ...
>>     ...
>>   </tr>
>> <% end -%>
Ciao Antonio oggi ho provato la soluzione pero mi accorgo che se nella
tabella phones non ci sono record giustamente il ciclo esce non creando 
<td><%=h phone.number %></td> nulla problema che pi si riversa nella
visualizzazione delle altre perche vengono anticipate mi dai la dritta 
su come posso risolvere il problema ?
Ciao Fabio
risolvere il problema ?
Posted by Alessandro Scolavino (ninjinka)
on 2010-09-01 16:13
> Ciao Antonio oggi ho provato la soluzione pero mi accorgo che se nella
> tabella phones non ci sono record giustamente il ciclo esce non creando 
> <td><%=h phone.number %></td> nulla problema che pi si riversa nella
> visualizzazione delle altre perche vengono anticipate mi dai la dritta 
> su come posso risolvere il problema ?
> Ciao Fabio
> risolvere il problema ?

un buon modo per risolverlo è assumere un programmatore
Posted by fdibe nedetto (fdibenedetto72)
on 2010-09-01 16:25
Alessandro Scolavino wrote:
> 
>> Ciao Antonio oggi ho provato la soluzione pero mi accorgo che se nella
>> tabella phones non ci sono record giustamente il ciclo esce non creando 
>> <td><%=h phone.number %></td> nulla problema che pi si riversa nella
>> visualizzazione delle altre perche vengono anticipate mi dai la dritta 
>> su come posso risolvere il problema ?
>> Ciao Fabio
>> risolvere il problema ?
> 
> un buon modo per risolverlo è assumere un programmatore
Ciao Alessandro,
Perche invece non mi dai una mano a capire come risolvere il problema?

saluti
fdibenedetto
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.