Module: Opinio::Controllers::Helpers

Defined in:
lib/opinio/controllers/helpers.rb

Instance Method Summary collapse

Instance Method Details

#comments_for(object, options = {}) ⇒ Object



5
6
7
8
# File 'lib/opinio/controllers/helpers.rb', line 5

def comments_for(object, options = {})        
  render_comments(object, options) +
  ( render_comments_form(object, options) unless options[:no_new] ).to_s
end

#render_comments(object, options = {}) ⇒ Object



10
11
12
13
14
# File 'lib/opinio/controllers/helpers.rb', line 10

def render_comments(object, options = {})
  limit = options.delete(:limit) || Opinio.model_name.constantize.default_per_page
  page  = options.delete(:page)  || 1
  render( :partial => "opinio/comments/comments", :locals => {:comments => object.comments.page(page).limit(limit), :commentable => object, :options => options} )
end

#render_comments_form(object, options = {}) ⇒ Object



16
17
18
# File 'lib/opinio/controllers/helpers.rb', line 16

def render_comments_form(object, options = {})
  render( :partial => "opinio/comments/new", :locals => {:commentable => object, :options => options} )
end