Ugghh.. posted this too soon. Discovered my problem. I was accidently
returning nil from a controller action will result in the message:
*NoMethodError: undefined method `each' for nil:NilClass*

since it sets the body to the output of the action, and it puts the
body directly into the rack_response

Seems like a fairly unhelpful error message when returning nil from a
controller. This will easily happen if someone adds a log statement or
something to the end of the action expecting it to work like rails and
render anyways.

Might be worth adding a message at the end of the merb_controller to
check for nil, and throw a proper exception with a message that the
action returned no output for the controller






Jacques Crocker wrote:
> Looks like there's a bit of a problem rendering template's in Merb
> 1.0.8.x. In a controller's action (search/index), if I say:
>
> def index
>   @posts = search_posts
>   render :template => "posts/index"
> end
>
> I get:
>
> Read error: #<NoMethodError: undefined method `each' for nil:NilClass>
> /Users/jc/Merb/stalkr/gems/gems/merb-core-1.0.8.1/lib/merb-core/rack/
> stream_wrapper.rb:18:in `each'
> /Users/jc/Merb/stalkr/gems/gems/merb-core-1.0.8.1/lib/merb-core/rack/
> handler/mongrel.rb:92:in `process'
>
>
> ----
>
> I spent quite a bit of time tracing it, and here are some interesting
> notes.
>
>
> If I just turn a string "TEST" from my action, it renders just fine
>
> If set render to a variable, and then return that string, it actually
> works which seems crazy to me
>
> def index
>   @posts = search_posts
>   tmp = render(:template => "posts/index")
>   return tmp
> end
>
> Has anyone seen this error before? I starting investigating rack/
> stream_wrapper and am not sure exactly what it's doing so its a bit
> tough to debug. The reason its breaking though is @body is nil so the
> StreamWrapper got initialized wrong.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to