creating dynamic helper methods in rails
问题 I am trying to create a bunch of dynamic helper methods like these: show_admin_sidebar show_posts_sidebar show_users_sidebar So far I have this in my helper.rb file: #spits out a partial def show_sidebar(name, show_sidebar = true) @content_for_sidebar = render :partial => "partials/#{name}" @show_sidebar = show_sidebar end def show_sidebar? @show_sidebar end In my application layout file I have this: (NB - I'm using HAML): - if show_sidebar? = yield(:sidebar) This allows me to say the