I made a simple plugin to explain a concept of render-filters.
In your controller,
ruby>>
class Posts < Application
before_render :set_title1, :only => :show
before :set_title2, :only => :show
def show(id)
@post = Post.get(id)
display @post
end
private
def set_title1
@title = @post.title # <= you can access to @post here
end
def set_title2
@title = @post.title #=> @post is nil!
end
end
<<--
Without this plugin, you couldn't access to instance variables from before-filters.
Of course you can prepare @post in the first before-filter so that you can access from other before-filters.
But why Merb has the action-args?
They are ignored in such case.
This was the problem I wanted to solve by the plugin.
posted by
takiuchi on Sun 1 Feb 2009 at 10:08 with 0 comments