Ciao a tutti,
non riesco a cancellare dei record.
Ogni suggerimento sarà vivamente apprezzato
Ecco quello che combino:
nel Controller:
def destroy
if params[:agtion_id] != nil
@agtion = Agtion.find(params[:agtion_id])
@course = Course.find(params[:id])
else
@agtion = Agtion.find(4) # 4 in locale, 7 in produzione
@course = Course.find(params[:id])
end
@course.destroy respond_to do |format|
format.html { redirect_to Agtion_courses_path(@agtion) }
format.xml { head :ok }
end
end
Errore:
ArgumentError in CoursesController#destroy
respond_to takes either types or a block, never both
RAILS_ROOT: F:/rubyProjects/fg
Application Trace | Framework Trace | Full Trace
F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/mime_responds.rb:103:in
respond_to' F:/rubyProjects/fg/app/controllers/courses_controller.rb:133:in
destroy’
F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/base.rb:1331:in
perform_action' F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/filters.rb:617:in
call_filters’
F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/filters.rb:610:in
perform_action_with_filters' F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
block in perform_action_with_benchmark’
F:/rubyProjects/fg/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in
block in ms' C:/Ruby191/lib/ruby/1.9.1/benchmark.rb:309:in
realtime’
F:/rubyProjects/fg/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in
ms' F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
perform_action_with_benchmark’
F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/rescue.rb:160:in
perform_action_with_rescue' F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/flash.rb:151:in
perform_action_with_flash’
F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/base.rb:532:in
process' F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/filters.rb:606:in
process_with_filters’
F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/base.rb:391:in
process' F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/base.rb:386:in
call’
F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:438:in
`call’
Request
Parameters:
{"_method"=>“delete”,
“authenticity_token”=>“uCi1a9tPIYxTQZ4ptme+SpZTXuTXn18OdPGPqK77+xQ=”,
“agtion_id”=>“7”,
“id”=>“5”}
Show session dump
Response
Headers:
{“Cache-Control”=>“no-cache”,
“Content-Type”=>""}
Un grazie anticipato a chiunque ha capito dove sbaglio… e me lo dice
On Tue, Apr 3, 2012 at 9:58 PM, An Car [email protected]
wrote:
@course.destroy respond_to do |format|
Il problema sembra essere in questa linea, prova a scriverla cos:
@course.destroy
respond_to do |format|
HTH.
– fabio
Grazie Fabio !
In effetti l’errore segnalato è stato risolto come hai detto: in
compenso ora me ne dà un altro:
NoMethodError in CoursesController#destroy
undefined method `Agtion_courses_path’ for
#CoursesController:0x46924a0
RAILS_ROOT: F:/rubyProjects/fg
Application Trace | Framework Trace | Full Trace
F:/rubyProjects/fg/app/controllers/courses_controller.rb:135:in block (2 levels) in destroy' F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/mime_responds.rb:135:in
call’
F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/mime_responds.rb:135:in
block in custom' F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/mime_responds.rb:179:in
call’
F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/mime_responds.rb:179:in
block in respond' F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/mime_responds.rb:173:in
each’
F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/mime_responds.rb:173:in
respond' F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/mime_responds.rb:107:in
respond_to’
F:/rubyProjects/fg/app/controllers/courses_controller.rb:134:in
destroy' F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/base.rb:1331:in
perform_action’
F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/filters.rb:617:in
call_filters' F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/filters.rb:610:in
perform_action_with_filters’
F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
block in perform_action_with_benchmark' F:/rubyProjects/fg/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in
block in ms’
C:/Ruby191/lib/ruby/1.9.1/benchmark.rb:309:in realtime' F:/rubyProjects/fg/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in
ms’
F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
perform_action_with_benchmark' F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/rescue.rb:160:in
perform_action_with_rescue’
F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/flash.rb:151:in
perform_action_with_flash' F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/base.rb:532:in
process’
F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/filters.rb:606:in
process_with_filters' F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/base.rb:391:in
process’
F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/base.rb:386:in
call' F:/rubyProjects/fg/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:438:in
call’
Request
Parameters:
{"_method"=>“delete”,
“authenticity_token”=>“UGUb1Ho+JKB8RNoQiRvMQPH/j5o0jcUEPrszkzxnWFI=”,
“agtion_id”=>“7”,
“id”=>“5”}
Show session dump
Response
Headers:
{“Cache-Control”=>“no-cache”,
“Content-Type”=>“text/html”}
Il 04/04/12 09:33, Andrea P. ha scritto:
cos a occhio direi che c’ un errore di battitura: Agtion_courses_path
dovrebbe essere agtion_courses_path
direi che il typo qui:
format.html { redirect_to Agtion_courses_path(@agtion) }
cos a occhio direi che c’ un errore di battitura: Agtion_courses_path
dovrebbe
essere agtion_courses_path
Il 04/04/2012 09:29, An Car ha scritto:
Eccezzionale (con due z !)
ora tutto funziona !
manaccia alla maiuscola !!!
Grazie di cuore a tutti.