Skip to content

issuehunter/minimal_feedback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MinimalFeedbackBuild Status

Feedback functionalities for ActiveRecord models

Usage

Add to Gemfile:

gem 'minimal_feedback'

Run:

bundle install
rails generate minimal_feedback
rake db:migrate

Quick Start

Let's say we have an Issue ActiveRecord model and we want to be able to give it feedback

class User < ActiveRecord::Base
  has_many :issues
end

class Issue < ActiveRecord::Base
  include MinimalFeedback

  attr_accessor :condition

  allow_feedback :if => proc { condition }

  belongs_to :user
end

What would happen with this configuration:

issue = Issue.create
issue.condition = true
issue.give_feedback(:positive)
issue.feedbacks.first.type
=> :positive

issue.give_feedback(:negative)
issue.feedbacks.last.type
=> :negative

If the condition proc returns false when the give_feedback method is called an ActiveRecord invalid exception is raised.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

Feedback functionalities for ActiveRecord models

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages