Errore con il passaggio di parametri

2010/8/31 Pietro G. [email protected]

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

Pietro G. wrote:

Il 31 agosto 2010 17:41, Fabio Di benedetto
[email protected] ha scritto:

Antonio C. 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

<%=h user.phones.find_all_by_typephone_id(1) %> riesco a vedere l'intero array ma a me serve prendere solo un campo sto benedetto number !!! fdibenedetto

Antonio C. wrote:

2010/8/31 Pietro G. [email protected]

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

Antonio C. wrote:

2010/8/31 Fabio Di benedetto [email protected]

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!!

2010/8/31 Fabio Di benedetto [email protected]

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

2010/8/31 Fabio Di benedetto [email protected]

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| %>

<%=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

Controller

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

View

<% @phones.each do |phone| %>

<%=h phone.number %> <% 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:

<%=h user.password %>
57: <%=h
Phone.find_by_user_id(user.id).to_s.split%>
58: <%=h
user.phones.find_all_by_typephone_id(1)%>
59: <% @phones.each do |phone| %>
60: <%=h phone.number%>
61: <% end -%>
62:

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:ineach’
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:inblock 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:inrender’
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:inrender’
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:inrender’
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:inrender’
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:inblock 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:inms’
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:indefault_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:incall_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:inblock 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:inrealtime’
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:inperform_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:inperform_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:inprocess_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:incall’
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:indispatch’
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:inblock 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:inblock 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:incache’
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:incall’
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:incall’
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:incall’
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:incall’
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:incall’
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:inrun’
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:incall’
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:ineach’
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:incall’
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:inservice’
C:/Ruby191/lib/ruby/1.9.1/webrick/httpserver.rb:111:in service' C:/Ruby191/lib/ruby/1.9.1/webrick/httpserver.rb:70:inrun’
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:inblock 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:inwith_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:inrender_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:inrender_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:inblock 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:inrealtime’
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:inrender_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:inperform_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:inperform_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:inblock 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:inms’
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:inperform_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:inprocess’
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:inprocess’
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:incall’
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:incall’
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:incache’
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:incall’
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:incall’
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:incall’
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:incall’
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:inblock 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:incall’
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:inrun’
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:incall’
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:ineach’
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:incall’
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:inservice’
C:/Ruby191/lib/ruby/1.9.1/webrick/httpserver.rb:111:in service' C:/Ruby191/lib/ruby/1.9.1/webrick/httpserver.rb:70:inrun’
C:/Ruby191/lib/ruby/1.9.1/webrick/server.rb:183:in `block in
start_thread’
Request
Parameters:

None

Antonio C. wrote:

On Tue, Aug 31, 2010 at 2:20 PM, Fabio Di benedetto <
[email protected]> 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 }

On Tue, Aug 31, 2010 at 2:20 PM, Fabio Di benedetto <
[email protected]> 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

2010/8/31 Fabio Di benedetto [email protected]

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

Fabio Di benedetto wrote:

Antonio C. wrote:

2010/8/31 Fabio Di benedetto [email protected]

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”}

Antonio C. wrote:

2010/8/31 Fabio Di benedetto [email protected]

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

Antonio C. wrote:

On Tue, Aug 31, 2010 at 3:18 PM, Fabio Di benedetto <
[email protected]> 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| %>

<%= user.name %> ... ... ... <% user.phone_numbers.each do |phone| %> <%=h phone.number %> <% end -%> ... ... <% 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 ! :slight_smile:
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!

Fabio Di benedetto wrote:

Antonio C. wrote:

On Tue, Aug 31, 2010 at 3:18 PM, Fabio Di benedetto <
[email protected]> 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| %>

<%= user.name %> ... ... ... <% user.phone_numbers.each do |phone| %> <%=h phone.number %> <% end -%> ... ... <% 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

<%=h phone.number %> 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 ?

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

<%=h phone.number %> 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

On Tue, Aug 31, 2010 at 3:18 PM, Fabio Di benedetto <
[email protected]> 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| %>

<%= user.name %> ... ... ... <% user.phone_numbers.each do |phone| %> <%=h phone.number %> <% end -%> ... ... <% 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

Alessandro S. 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

<%=h phone.number %> 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