Module: Commenter::Helpers
- Defined in:
- lib/commenter/helpers.rb
Instance Method Summary collapse
Instance Method Details
#commentable(params = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/commenter/helpers.rb', line 3 def commentable(params={}) if res=params[:resource] id = res.id klass = res.class.to_s else raise "invalid parameters" end comments = Comment.where(:resource_class => klass, :resource_id => id) new_comment = Comment.new(:resource_class => klass, :resource_id => id) locals = {:comments => comments, :new_comment => new_comment, :resource => res} html = render(:partial => 'comments/index', :locals => locals) html.html_safe end |