Forum: Italian Ruby user group errore parametri form_tag

Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-19 12:21
Salve ragazzi,
ho un problema con form_tag
la pagina e' cosi scritta:
<h1>Nuovo Numero</h1>
<%form_tag :action=>'cnew' , :user_id =>@user  do %>
<p>User id<%= text_field_tag 'user_id',@user %></p>
<p>Numero di telefono<%= text_field_tag 'number' %></p>

<p>
   <%= submit_tag "Aggiungi Numero"  %>
</p>

<% end %>

nel controller
  def cnew
    @phone =Phone.find(:first , :conditions =>["number =?",
params[:number]])
    if @phone.nil == true  then
      @phone.new
        @phone.user_id=@user
        @phone.number=params[:number]
      @phone.save
    end
    if @phone.save
      redirect_to @phone
    else
       render :action => "new"
    end
  end

Quando premo il pulsante  aggiungi numero mi restituisce questo errore
undefined method `nil' for nil:NilClass
Potreste aitarmi a capire gli errori?
Grazie Fdibenedetto
Posted by Andrea Pavoni (apeacox)
on 2010-08-19 12:41
(Received via mailing list)
sarebbe utile conoscere un altro po' di errore, generalmente indica
anche il file e la riga che hanno restituito l'errore, altrimenti rimane
un po' dura (anche se sarebbe comodo avere un debugger innestato nel
cervello :D) :P

ciao,
A.

Il 19/08/2010 12:21, Fabio Di benedetto ha scritto:
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-19 13:12
Ti Posto l'errore
ciao fdibenedetto
NoMethodError in PhonesController#cnew
undefined method `nil' for nil:NilClass
RAILS_ROOT: C:/testapp

Application Trace | Framework Trace | Full Trace
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/whiny_nil.rb:52:in 
`method_missing'
C:/testapp/app/controllers/phones_controller.rb:39:in `cnew'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/whiny_nil.rb:52:in 
`method_missing'
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/activesupport-2.3.8/lib/active_support/whiny_nil.rb:52:in 
`method_missing'
C:/testapp/app/controllers/phones_controller.rb:39:in `cnew'
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:

{"authenticity_token"=>"vvrZMyzklLaATQA+yAKKzEJSb665m3C9/U9yI5zQzIM=",
 "user_id"=>"1",
 "number"=>"2",
 "commit"=>"Aggiungi Numero"}

Show session dump

---

Response
Headers:

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



Andrea Pavoni wrote:
> sarebbe utile conoscere un altro po' di errore, generalmente indica
> anche il file e la riga che hanno restituito l'errore, altrimenti rimane
> un po' dura (anche se sarebbe comodo avere un debugger innestato nel
> cervello :D) :P
> 
> ciao,
> A.
> 
> Il 19/08/2010 12:21, Fabio Di benedetto ha scritto:
Posted by Andrea Pavoni (apeacox)
on 2010-08-19 13:25
(Received via mailing list)
ok, trovato l'errore ;)

nel controller hai:

if @phone.nil == true  then
       @phone.new
       @phone.user_id=@user
       @phone.number=params[:number]
       @phone.save
end

è meglio riscriverlo 
così:
if @phone.nil? #<= qui era l'errore, il controllo lo fai con 'nil?'
   @phone.new(:user_id =>  @user, :number =>  params[:number])
end

if @phone.save #etc...

ci sarebbero altri miglioramenti sintattici e logici che potresti 
apportare, in ogni caso l'errore è risolto ;)

ciao,
A.



Il 19/08/2010 13:12, Fabio Di benedetto ha scritto:
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-19 15:05
Andrea, ho provato a fare cio che mi scrivi con qualche modifica
ti riporto il codice della view e del controller
la view e'
<h1>Nuovo Numero</h1>
<%form_tag :action=>'cnew' , :user_id =>@user  do %>
<p>User id<%= text_field_tag 'user_id',@user %></p>
<p>Numero di telefono<%= text_field_tag 'number' %></p>

<p>
   <%= submit_tag "Aggiungi Numero"  %>
</p>

<% end %>

il controller cnew l'ho cosi modificato:
    @phone =Phone.find(:first , :conditions =>["number 
=?",params[:number]])
   if @phone.nil?
    @phone=Phone.new(:user_id =>   params[:number], :number => 
params[:number])
  end
    if @phone.save
      redirect_to @phone
    else
      render :action => "new"
    end
  end

ma mi restituisc questo errore
Mysql::Error: Duplicate entry '2' for key 1: INSERT INTO `phones` 
(`number`, `created_at`, `updated_at`, `user_id`) VALUES('3', 
'2010-08-19 13:04:34', '2010-08-19 13:04:34', 3)
RAILS_ROOT: C:/testapp

Application Trace | Framework Trace | Full Trace
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract_adapter.rb:221:in 
`rescue in log'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract_adapter.rb:204:in 
`log'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/mysql_adapter.rb:323:in 
`execute'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/database_statements.rb:259:in 
`insert_sql'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/mysql_adapter.rb:333:in 
`insert_sql'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/database_statements.rb:44:in 
`insert'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/query_cache.rb:19:in 
`insert_with_query_dirty'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:2949:in 
`create'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/timestamp.rb:53:in 
`create_with_timestamps'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/callbacks.rb:266:in 
`create_with_callbacks'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:2915:in 
`create_or_update'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/callbacks.rb:250:in 
`create_or_update_with_callbacks'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:2573:in 
`save'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/validations.rb:1090:in 
`save_with_validation'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/dirty.rb:79:in 
`save_with_dirty'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:229:in 
`block in with_transaction_returning_status'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in 
`transaction'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:182:in 
`transaction'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:228:in 
`with_transaction_returning_status'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:196:in 
`block in save_with_transactions'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:208:in 
`rollback_active_record_state!'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:196:in 
`save_with_transactions'
C:/testapp/app/controllers/phones_controller.rb:40:in `cnew'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract_adapter.rb:221:in 
`rescue in log'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract_adapter.rb:204:in 
`log'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/mysql_adapter.rb:323:in 
`execute'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/database_statements.rb:259:in 
`insert_sql'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/mysql_adapter.rb:333:in 
`insert_sql'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/database_statements.rb:44:in 
`insert'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/query_cache.rb:19:in 
`insert_with_query_dirty'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:2949:in 
`create'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/timestamp.rb:53:in 
`create_with_timestamps'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/callbacks.rb:266:in 
`create_with_callbacks'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:2915:in 
`create_or_update'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/callbacks.rb:250:in 
`create_or_update_with_callbacks'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:2573:in 
`save'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/validations.rb:1090:in 
`save_with_validation'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/dirty.rb:79:in 
`save_with_dirty'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:229:in 
`block in with_transaction_returning_status'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in 
`transaction'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:182:in 
`transaction'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:228:in 
`with_transaction_returning_status'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:196:in 
`block in save_with_transactions'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:208:in 
`rollback_active_record_state!'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:196:in 
`save_with_transactions'
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/connection_adapters/abstract_adapter.rb:221:in 
`rescue in log'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract_adapter.rb:204:in 
`log'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/mysql_adapter.rb:323:in 
`execute'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/database_statements.rb:259:in 
`insert_sql'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/mysql_adapter.rb:333:in 
`insert_sql'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/database_statements.rb:44:in 
`insert'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/query_cache.rb:19:in 
`insert_with_query_dirty'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:2949:in 
`create'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/timestamp.rb:53:in 
`create_with_timestamps'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/callbacks.rb:266:in 
`create_with_callbacks'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:2915:in 
`create_or_update'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/callbacks.rb:250:in 
`create_or_update_with_callbacks'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/base.rb:2573:in 
`save'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/validations.rb:1090:in 
`save_with_validation'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/dirty.rb:79:in 
`save_with_dirty'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:229:in 
`block in with_transaction_returning_status'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in 
`transaction'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:182:in 
`transaction'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:228:in 
`with_transaction_returning_status'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:196:in 
`block in save_with_transactions'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:208:in 
`rollback_active_record_state!'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activerecord-2.3.8/lib/active_record/transactions.rb:196:in 
`save_with_transactions'
C:/testapp/app/controllers/phones_controller.rb:40:in `cnew'
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:

{"authenticity_token"=>"vvrZMyzklLaATQA+yAKKzEJSb665m3C9/U9yI5zQzIM=",
 "user_id"=>"1",
 "number"=>"3",
 "commit"=>"Aggiungi Numero"}

Show session dump

---

Response
Headers:

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





RAILS_ROOT: C:/testapp

Application Trace | Framework Trace | Full Trace
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/whiny_nil.rb:52:in 
`method_missing'
C:/testapp/app/controllers/phones_controller.rb:44:in `cnew'
C:/Ruby191/lib/ruby/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/whiny_nil.rb:52:in 
`method_missing'
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/activesupport-2.3.8/lib/active_support/whiny_nil.rb:52:in 
`method_missing'
C:/testapp/app/controllers/phones_controller.rb:44:in `cnew'
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:

{"authenticity_token"=>"vvrZMyzklLaATQA+yAKKzEJSb665m3C9/U9yI5zQzIM=",
 "user_id"=>"1",
 "number"=>"3",
 "commit"=>"Aggiungi Numero"}

Show session dump

---

Response
Headers:

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

Andrea Pavoni wrote:
> ok, trovato l'errore ;)
> 
> nel controller hai:
> 
> if @phone.nil == true  then
>        @phone.new
>        @phone.user_id=@user
>        @phone.number=params[:number]
>        @phone.save
> end
> 
> � meglio riscriverlo 
> cos�:
if @phone.nil? #<= qui era l'errore, il controllo lo fai con 'nil?'
>    @phone.new(:user_id =>  @user, :number =>  params[:number])
> end
> 
> if @phone.save #etc...
> 
> ci sarebbero altri miglioramenti sintattici e logici che potresti 
> apportare, in ogni caso l'errore � risolto ;)
> 
> ciao,
> A.
> 
> 
> 
> Il 19/08/2010 13:12, Fabio Di benedetto ha scritto:
Posted by Andrea Pavoni (apeacox)
on 2010-08-19 15:16
(Received via mailing list)
prova a leggere questo thread

ciao,
A.

Il 19/08/2010 15:05, Fabio Di benedetto ha scritto:
Posted by Andrea Pavoni (apeacox)
on 2010-08-19 15:18
(Received via mailing list)
ops! ho dimenticato il link:

http://forums.mysql.com/read.php?136,168833,168833#msg-168833

ciao,
A.

Il 19/08/2010 15:05, Fabio Di benedetto ha scritto:
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-19 15:51
Ok funziona !!
grazie andrea!!
i tuoi consigli mi hanno risolto questo problema .
capisco bene  e' un piccolo problema ma all'inizio e' tutto cosi 
complicato!!!
Perfavore mi puoi spiegare la logica if @phone.nil?
if @phone.nil?
a rigor di logica s'intende che se non se non esiste il record allora 
esegue il codice sottostante ma perche il ? e non ==TRUE

Grazie sempre

Fdibenedetto
Andrea Pavoni wrote:
> ops! ho dimenticato il link:
> 
> http://forums.mysql.com/read.php?136,168833,168833#msg-168833
> 
> ciao,
> A.
> 
> Il 19/08/2010 15:05, Fabio Di benedetto ha scritto:
Posted by Andrea Pavoni (apeacox)
on 2010-08-19 16:12
(Received via mailing list)
'nil?' è un metodo, restituisce 'true' se l'oggetto che lo ha chiamato è nil

non ha senso confrontarlo ulteriormente con un valore bool, sarebbe come
dire:

if (1 > 2) == false

tra l'altro, il primo errore che ricevevi era dovuto al fatto che non
esiste un metodo '.nil' per gli oggetti, non per default ;-)

NOTA  A MARGINE: è vero che spesso la pratica insegna più della teoria,
ma questo non significa che per pilotare un elicottero sia sufficiente
salirci sopra e provare ad accenderlo. magari con un po' di
documentazione e qualche ricerca su google potresti anche imparare di 
più.
ciao,
A.

Il 19/08/2010 15:51, Fabio Di benedetto ha scritto:
Posted by fdibe nedetto (fdibenedetto72)
on 2010-08-19 16:18
Infatti occorre fare l'uno e l'altro
Grazie sempre per i tuoi suggerimenti
Andrea Pavoni wrote:
> 'nil?' � un metodo, restituisce 'true' se l'oggetto che lo ha chiamato � nil
> 
> non ha senso confrontarlo ulteriormente con un valore bool, sarebbe come
> dire:
> 
> if (1 > 2) == false
> 
> tra l'altro, il primo errore che ricevevi era dovuto al fatto che non
> esiste un metodo '.nil' per gli oggetti, non per default ;-)
> 
> NOTA  A MARGINE: � vero che spesso la pratica insegna pi� della teoria,
> ma questo non significa che per pilotare un elicottero sia sufficiente
> salirci sopra e provare ad accenderlo. magari con un po' di
> documentazione e qualche ricerca su google potresti anche imparare di 
> pi�.
ciao,
> A.
> 
> Il 19/08/2010 15:51, Fabio Di benedetto ha scritto:
Posted by Aldo Italo (aldoitalo)
on 2010-08-23 00:10
Fabio Di benedetto wrote:
> Infatti occorre fare l'uno e l'altro
> Grazie sempre per i tuoi suggerimenti

si, ma prima inizia con un buon manuale (anche più di 1 se puoi, ti 
consiglio questi: http://www.pragprog.com )

comunque:
if @phone.nil?

è come scrivere:
if @phone == nil

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.