Skip to content

Commit

Permalink
Added conditions to the model
Browse files Browse the repository at this point in the history
  • Loading branch information
fred committed Apr 13, 2012
1 parent 603255e commit 1614b8a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ This can also be used on the `comments_for` helper.

== Customization

=== Models

If you want to have custom conditions to the comment model you can add as such.
Example, you only want to load approved comments:

opinio_subjectum :conditions => {:approved => true }

and also eager load associations

opinio_subjectum :conditions => {:approved => true }, :include => :owner


=== Views

Of course you will want to customize how the comments are displayed or any other customization to the view. To generate the view files on your application, run:
Expand Down
2 changes: 2 additions & 0 deletions lib/opinio/opinio_subjectum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ def opinio_subjectum(*args)
options = args.extract_options!

has_many :comments,
:conditions => options[:conditions],
:include => options[:include],
:class_name => Opinio.model_name,
:as => :commentable,
:order => options.reverse_merge(:order => "created_at #{Opinio.sort_order}")[:order],
Expand Down

0 comments on commit 1614b8a

Please sign in to comment.