Strange unexplainable error

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:into_s’
vendor/rails/actionpack/lib/action_controller/layout.rb:241:in
render_without_benchmark' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:inrender’
/usr/local/lib/ruby/1.8/benchmark.rb:293:in measure' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:inrender’
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

Nevermind, it turned out to be a problem with map_by_method as
described at
http://drnicwilliams.com/2007/08/12/map_by_method-now-works-with-activerecord-associations/
(comment 8 and following)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs