Controller instance variables falling in and out of scope


#1

Very bizarre behavior has cropped up in a few spots.

the action for viewing a blog post

def posts
@post = BlogPost.find_by_slug(params[:id], :include => :commentary)

a breakpoint here shows @post and @post.commentary with appropriate

data
redirect_to :action => ‘archive’ unless @post
end

posts.rhtml

<%= @post.inspect %> => nil
<%= render :partial => ‘post’, :object => @post %> => renders with
correct data
<%= @post.comments %> => NoMethodError
<%= render_tree_of( @post.comments, … ) %> => generates no errors,
but within the partial reports @post.comments as nil

WinXP
Ruby 1.8.2
Edge Rails (behavior has existed over several iterations now)

I’ve not run into anybody else with this problem, and have not had
much luck with IRC and my own debugging efforts. Any clues?


Seth Thomas R.
http://sethrasmussen.com/


#2

I should probably add that BlogPost#comments is defined to return a
mapped version of BlogPost#commentary.

On 3/22/06, Seth R. removed_email_address@domain.invalid wrote:

<%= @post.inspect %> => nil
much luck with IRC and my own debugging efforts. Any clues?


Seth Thomas R.
http://sethrasmussen.com/


Seth Thomas R.
http://sethrasmussen.com/


#3

Turns out it was a filter in ApplicationController calling
render_to_string… interesting behavior nonetheless.

On 3/22/06, Seth R. removed_email_address@domain.invalid wrote:

redirect_to :action => ‘archive’ unless @post
Ruby 1.8.2


Seth Thomas R.
http://sethrasmussen.com/


Seth Thomas R.
http://sethrasmussen.com/