# Strange unexplainable error

**URL:** <https://www.ruby-forum.com/t/strange-unexplainable-error/112795>\
**Category:** Rails\
**Created:** [August 23, 2007, 11:26am UTC](https://www.ruby-forum.com/t/strange-unexplainable-error/112795 "2007-08-23T11:26:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/57b2e6/32.png) [@martinos](https://www.ruby-forum.com/u/martinos)\
**Post date:** [August 23, 2007, 11:26am UTC](https://www.ruby-forum.com/t/strange-unexplainable-error/112795/1 "2007-08-23T11:26:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![martinos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/57b2e6/32.png) [@martinos](https://www.ruby-forum.com/u/martinos)\
**Post date:** [August 23, 2007, 11:43am UTC](https://www.ruby-forum.com/t/strange-unexplainable-error/112795/2 "2007-08-23T11:43:06Z")

</div>

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/](http://drnicwilliams.com/2007/08/12/map_by_method-now-works-with-activerecord-associations/)  
(comment 8 and following)
