I made a simple plugin to explain a concept of render-fil
In your controller
1 class Posts < Application 2 before_ren der :set_title1 , :only => :show 3 before :set_title2 , :only => :show 4 5 def show(id) 6 @post = Post.get(id) 7 display @post 8 end 9 10 private 11 def set_title1 12 @title = @post.title # <= you can access to @post here 13 end 14 15 def set_title2 16 @title = @post.title #=> @post is nil! 17 end 18 end
Without this plugin, you couldn't access to instance variables from before-fil
posted by
takiuchi
on Sun 1 Feb 2009
at 10:19