In one of my Controllers I stumbled upon a really strange error. On
render :action => :create I get this error message:
NoMethodError in Admin/machines/baseController#save
undefined method `to_str'' for [:action, :create]:Array
Application Trace:
/usr/local/lib/ruby/gems/1.8/gems/map_by_method-0.7.0/lib/
map_by_method.rb:12:in `method_missing''
vendor/rails/actionpack/lib/action_controller/layout.rb:241:in `to_s''
vendor/rails/actionpack/lib/action_controller/layout.rb:241:in
`render_without_benchmark''
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in
`render''
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure''
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in
`render''
app/controllers/admin/machines/base_controller.rb:22:in `save''
I''ve done rendering actions probably a hundred times before and I
don''t see anything wrong with my code. But just for good measure
here''s the code I''m using. When saving fails because of some
validation errors it is supposed to render the create view again but
dies with the above error message.
class Admin::Machines::BaseController < ApplicationController
def create
@machine = Machine::Base.new
@picture = Picture.new
end
def save
@machine = Machine::Base.new(params[:machine])
@picture = Picture.new(params[:picture])
@machine.picture = @picture
if @machine.save && @picture.save
flash[:notice] = "yay!"
redirect_to :action => :index
else
flash[:error] = "nay"
render :action => :create
end
end
end
Cheers
Martin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---