Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Migrate to Rails 5.2 #92

Open
wants to merge 82 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
c0c9d6f
Updated Ruby version
wazery Jul 6, 2014
00696b2
Added Travis image, and explained fork cause
wazery Jul 6, 2014
180ae27
Renamed create_migration method to avoid collision with Rails
wazery Jul 6, 2014
035c502
Minor changes to readme
wazery Jul 19, 2014
fb40619
Added the ratyrate changelog
wazery Jul 29, 2014
767f8b0
Added ratyrate v.1.2.0.alpha features
wazery Jul 30, 2014
58b599d
Added ratyrate v.1.2.0.alpha features
wazery Jul 30, 2014
22fdf05
Merge branch 'development'
wazery Aug 13, 2014
dfd263c
add db:migrate to README, fix inconsistent capitalization
nbirnel Aug 22, 2014
51ebf9a
Merge pull request #43 from nbirnel/improve-readme
wazery Aug 23, 2014
eb32400
Removed spec files from master
wazery Aug 24, 2014
b1238f9
Merge branch 'master', update gem version to 1.2.2.alpha
wazery Aug 24, 2014
7437a8c
Fix rating_for_user
jq-jay Oct 1, 2014
e45df05
Updating TODO status
wazery Oct 1, 2014
4474648
Merge pull request #45 from jwako/master
wazery Oct 1, 2014
ad4de39
Update README.md
wazery Oct 28, 2014
fc774f4
fix not display stars with turbolinks
hechen0 Oct 29, 2014
5d11d6f
fix not display stars with turbolinks
hechen0 Oct 29, 2014
4467889
Merge pull request #48 from Nxbtch/master
wazery Nov 9, 2014
7739476
Small fixes to make STI working correctly
zewelor Nov 12, 2014
76b587c
Update README.md
wazery Nov 13, 2014
3809197
Merge pull request #49 from canncast/sti_fixes
wazery Nov 26, 2014
cbb40b5
Fix error when reflecting on associations.
joeyates Nov 28, 2014
170ac92
Merge pull request #51 from bookempire/feature/fix_association
wazery Nov 28, 2014
f71ffef
data-cancel should be treated as boolean value, not string
alexanderad Nov 30, 2014
d76d959
Fix original repo name
wazery Dec 2, 2014
1cd25dc
Merge pull request #52 from alexanderad/fix_for_cancel_button
wazery Jan 19, 2015
f6d18b0
add waffle.io badge
waffle-iron Jan 23, 2015
4ab1936
Merge pull request #59 from waffle-iron/master
wazery Jan 23, 2015
0fc6e99
Update README.md
wazery Jan 24, 2015
5af220f
calculate_overall_average
Feb 3, 2015
6d5ed8a
Fix rates(dimension) in model.
Feb 11, 2015
8dbf161
Fixed image paths
wazery Mar 8, 2015
f14e570
prefixed the image_path with '/'
onlinetocode Mar 16, 2015
b51728e
Update README.md
onlinetocode Mar 16, 2015
9ea0c40
Update helpers.rb
onlinetocode Mar 16, 2015
6739a41
read only test
onlinetocode Mar 16, 2015
70c804f
Update helpers.rb
onlinetocode Mar 16, 2015
4b7b316
Merge pull request #60 from shah743/patch-1
wazery Mar 25, 2015
1382a88
Merge pull request #63 from link60/fix_rates_dimension
wazery Mar 25, 2015
b2744a3
Merge pull request #72 from onlinetocode/master
wazery Mar 25, 2015
19b75a5
Fixes IMDB big star image path
VarunBatraIT Mar 25, 2015
9de2cca
Merge pull request #74 from VarunBatraIT/master
wazery Mar 31, 2015
c71d78e
Add Omniref badge
wazery Apr 3, 2015
59897e0
Update README.md
wazery Apr 3, 2015
f3038bf
Polish code to Ruby 2 hash syntax
wazery Apr 7, 2015
67ff67e
Trigger an event when there is a new rating
pablof7z Apr 9, 2015
62e4be0
Update to Ruby 2 hash syntax
wazery Apr 11, 2015
0d6be55
Update to Ruby 2 hash syntax
wazery Apr 11, 2015
f0b0c4b
Add a Bitdeli badge to README
bitdeli-chef May 11, 2015
abd6419
Merge pull request #82 from bitdeli-chef/master
wazery May 11, 2015
8798cc1
Fix default value for :readonly option
May 14, 2015
77b1b9b
Fix assets url
May 14, 2015
5d7787b
Fix assets url (2)
May 14, 2015
40f0870
fix jquery.raty.js not found error
sonalkr132 May 15, 2015
6e74ba8
Merge pull request #83 from sonalkr132/master
wazery May 15, 2015
ef6098c
fixed typo in README.md
aniliyidogan Aug 22, 2015
6a9967e
Changed image path in helpers.rb, it was not working on heroku
yihyang Sep 12, 2015
f384bc5
Fix to work with STI in Rails
jonatassalgado Sep 12, 2015
36db432
Merge pull request #93 from aniliyidogan/master
wazery Sep 12, 2015
f62199f
Merge pull request #94 from yihyang/master
wazery Sep 12, 2015
64d7234
Merge pull request #84 from n-rodriguez/master
wazery Sep 12, 2015
e80b1b1
Merge pull request #95 from jonatassalgado/master
wazery Sep 12, 2015
b4f270d
Update jquery.raty.js.erb
veduket Oct 13, 2015
c42c52f
Merge pull request #98 from veduket/patch-1
wazery Oct 13, 2015
d6af237
Activates readonly option
Dec 18, 2015
c84829f
Applies corrections
Dec 19, 2015
61487c4
Merge pull request #105 from 6temes/feature/activates_readonly
wazery Dec 19, 2015
864bc45
add index for migration
Mar 1, 2016
ed2f020
Merge pull request #111 from dimasjt/master
wazery Jun 15, 2016
ae857f7
Merge pull request #78 from heelhook/master
wazery Jun 15, 2016
b738c56
Update hash syntax to Ruby 2 style
wazery Jun 15, 2016
fc5e7fe
Fix rate_for_user recognizes wrong rateable_type for polymorphic
sangnuce Nov 24, 2016
e1c016f
Add CodeTriage badge to the README, Fix broken image
wazery Jul 20, 2017
51148f0
Updated ruby version to `2.2.2`
yihyang Oct 9, 2017
6efb578
Bundle updated gem
yihyang Oct 9, 2017
c2b8ea7
Merge pull request #150 from yihyang/update_dependencies
wazery Oct 18, 2017
d61cfb7
Merge pull request #134 from sangnuce/master
wazery Oct 18, 2017
d37a452
wrapped helpers and model under Ratyrate namespacing (#161)
yihyang Oct 4, 2018
fe45d90
Direct inherit mig fix (#162)
yihyang Oct 4, 2018
05d704c
uncommented index on migration template
yihyang Oct 4, 2018
8c65dbf
Merge pull request #1 from wazery/master
azizmashkour Oct 5, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
language: ruby
rvm:
- "1.9.2"
- "1.9.3"
- "2.0.0"
- rbx-18mode
- rbx-19mode
- "2.2.2"
# uncomment this line if your project needs to run something other than `rake`:
# script: bundle exec rspec spec
# script: bundle exec rspec spec
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
source "http://rubygems.org"

gem 'jquery-rails'
gem 'jquery-rails', '~> 4.3', '>= 4.3.1'

ruby '2.2.2'

# gem 'rspec'

# Specify your gem's dependencies in letsrate.gemspec
gemspec
94 changes: 60 additions & 34 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,49 +1,75 @@
PATH
remote: .
specs:
letsrate (1.0.9)
ratyrate (1.2.2.alpha)

GEM
remote: http://rubygems.org/
specs:
actionpack (4.0.2)
activesupport (= 4.0.2)
builder (~> 3.1.0)
erubis (~> 2.7.0)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
activesupport (4.0.2)
i18n (~> 0.6, >= 0.6.4)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
atomic (1.1.14)
builder (3.1.4)
erubis (2.7.0)
i18n (0.6.9)
jquery-rails (3.0.4)
railties (>= 3.0, < 5.0)
actionpack (5.1.4)
actionview (= 5.1.4)
activesupport (= 5.1.4)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.1.4)
activesupport (= 5.1.4)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activesupport (5.1.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
builder (3.2.3)
concurrent-ruby (1.0.5)
crass (1.0.2)
erubi (1.6.1)
i18n (0.8.6)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
minitest (4.7.5)
multi_json (1.8.2)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
railties (4.0.2)
actionpack (= 4.0.2)
activesupport (= 4.0.2)
loofah (2.1.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
method_source (0.9.0)
mini_portile2 (2.3.0)
minitest (5.10.3)
nokogiri (1.8.1)
mini_portile2 (~> 2.3.0)
rack (2.0.3)
rack-test (0.7.0)
rack (>= 1.0, < 3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.1.4)
actionpack (= 5.1.4)
activesupport (= 5.1.4)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.1.1)
thor (0.18.1)
thread_safe (0.1.3)
atomic
tzinfo (0.3.38)
rake (12.1.0)
thor (0.20.0)
thread_safe (0.3.6)
tzinfo (1.2.3)
thread_safe (~> 0.1)

PLATFORMS
ruby

DEPENDENCIES
jquery-rails
letsrate!
jquery-rails (~> 4.3, >= 4.3.1)
ratyrate!

RUBY VERSION
ruby 2.2.2p95

BUNDLED WITH
1.15.4
165 changes: 138 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,97 @@
# Letsrate Rating Gem
# RatyRate Stars Rating Gem

Provides the best way to add rating capabilites to your Rails application with jQuery Raty plugin.
A Ruby Gem that wrap the functionality of [jQuery Raty](https://github.com/wbotelhos/raty) library, and provides optional IMDB style rating.

[![Build Status](https://secure.travis-ci.org/muratguzel/letsrate.png)](http://travis-ci.org/muratguzel/letsrate)
[![Dependency Status](https://gemnasium.com/muratguzel/letsrate.png)](https://gemnasium.com/muratguzel/letsrate)
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/muratguzel/letsrate)
[![Gem Version](https://badge.fury.io/rb/ratyrate.svg)](http://badge.fury.io/rb/ratyrate)
[![Build Status](https://travis-ci.org/wazery/ratyrate.svg)](http://travis-ci.org/wazery/ratyrate)
[![Dependency Status](https://gemnasium.com/wazery/ratyrate.svg)](https://gemnasium.com/wazery/ratyrate)
[![Code Climate](https://codeclimate.com/github/wazery/ratyrate.png)](https://codeclimate.com/github/wazery/ratyrate)
[![License](http://img.shields.io/license/MIT.png?color=green)](http://opensource.org/licenses/MIT)
[![Support jQuery Raty](http://img.shields.io/gittip/wbotelhos.svg)](https://www.gittip.com/wazery "Git Tip")
[![Stories in Ready](https://badge.waffle.io/wazery/ratyrate.png?label=ready&title=Ready)](https://waffle.io/wazery/ratyrate)
[![Code Triagers Badge](https://www.codetriage.com/wazery/ratyrate/badges/users.svg)](https://www.codetriage.com/wazery/ratyrate)

## Repository

Find it at [github.com/muratguzel/letsrate](https://github.com/muratguzel/letsrate)
This is a fork against the repository [muratguzel/letsrate](https://github.com/muratguzel/letsrate), the aim of this fork is to refresh the development in this Gem with a new scope and features, so please if you have any pull request issue it here, also I imported all the issues in the original repo.

## Changelog from the main repository

1. Exposed a lot of jQuery Raty plugin [features](http://wbotelhos.com/raty)
1. Added cancel button that can be customized and inserted to left or right
2. Added the ability to set custom star images for on, half or off state
3. Added the ability to set a custom path for the images
4. Added the ability to enable/disable half stars
5. Added the ability to turn on/off half star
2. Their is a new option now to disable or enable the rating after the first rate
3. Added a star style to show just the score of the dimension, but this star is not editable
4. Added an overall average star just like IMDB style
5. Created a Heroku app to illustrate this Gem's purpose and features (MovieStore)
6. [Wrote a complete tutorial on SitePoint that illustrates how to use this gem](http://www.sitepoint.com/ratyrate-add-rating-rails-app/)
3. Nothing else
4. :wq

## TODO

1. Write RSpec tests for this Gem
3. Add option to show the number of users who gave rates
4. Add a share helper to Facebook, Twitter
5. Force refresh after rating when ***disable_after_rate*** and ***imdb_avg*** options is set to true.

## Detailed view of the new features

![Detailed view of the new featurews](http://i.imgur.com/m6n25ZF.png)

## Complete tutorial for this Gem on SitePoint - Ruby

I wrote a complete tutorial on SitePoint to cover this Gem's features in detail, if you are concerned to learn more about it just pay a visit to this [link](http://www.sitepoint.com/ratyrate-add-rating-rails-app/).

## Instructions

### Install

Add the letsrate gem into your Gemfile
Add the ratyrate gem into your Gemfile

```ruby
gem 'letsrate'
gem 'ratyrate'
```

### Generate

```
rails g letsrate User
rails g ratyrate user
```

The generator takes one argument which is the name of your existing devise user model UserModelName. This is necessary to bind the user and rating datas.
Also the generator copies necessary files (jquery raty plugin files, star icons and javascripts)
Also the generator copies necessary files (jQuery Raty plugin files, star icons and JavaScript files)

Example:

Suppose you will have a devise user model which name is User. The devise generator and letsrate generator should be like below
Suppose you will have a devise user model which name is User. The devise generator and ratyrate generator should be like below

```
rails g devise:install
rails g devise user

rails g letsrate user # => user is the model generated by devise
rails g ratyrate user # => user is the model generated by devise
```

This generator will create Rate and RatingCache models and link to your user model.
This generator will create Rate and RatingCache models,
db/migrations,
and link to your user model.

### Database Migration

Run the migrations:
```
rake db:migrate
```

### Javascript include
```
//= require jquery.raty
//= require ratyrate
```

### Prepare

Expand All @@ -50,19 +101,19 @@ I suppose you have a car model
rails g model car name:string
```

You should add the letsrate_rateable function with its dimensions option. You can add multiple dimensions.
You should add the ratyrate_rateable function with its dimensions option. You can add multiple dimensions.

```ruby
class Car < ActiveRecord::Base
letsrate_rateable "speed", "engine", "price"
ratyrate_rateable "speed", "engine", "price"
end
```

Then you need to add a call letsrate_rater in the user model.
Then you need to add a call ratyrate_rater in the user model.

```ruby
class User < ActiveRecord::Base
letsrate_rater
ratyrate_rater
end
```

Expand All @@ -74,25 +125,85 @@ new rating value from authenticated user.
```erb
<%# show.html.erb -> /cars/1 %>

Speed : <%= rating_for @car, "speed" %>
Engine : <%= rating_for @car, "engine" %>
Price : <%= rating_for @car, "price" %>
Speed : <%= rating_for @car, 'speed' %>
Engine : <%= rating_for @car, 'engine' %>
Price : <%= rating_for @car, 'price' %>
```

If you need to change the star number, you should use star option like below.
### Available Options

1- If you need to change the star number, you should use star option like below.
```erb
Speed : <%= rating_for @car, "speed", :star => 10 %>
Speed : <%= rating_for @car, "engine", :star => 7 %>
Speed : <%= rating_for @car, "price" %>
Speed : <%= rating_for @car, 'speed', star: 10 %>
Engine : <%= rating_for @car, 'engine', star: 7 %>
Price : <%= rating_for @car, 'price' %>
```
2- If you want to disable/enable the rating after user's first rate use the new option *disable_after_rate*
```erb
Speed : <%= rating_for @car, 'speed', disable_after_rate: true %>
```
To enable changes after first user rate set ```disable_after_rate``` to false

You can use the rating_for_user helper method to show the star rating for the user.
3- To enable half stars use the option *enable_half*
```erb
Speed : <%= rating_for @car, 'speed', enable_half: true %>
```
4- To show or hide the half stars use *half_show*
```erb
Speed : <%= rating_for @car, 'speed', half_show: true %>
```
5- To change the path in which the star images (star-on.png, star-off.png, star-half.png, ..etc) are located use
```erb
Speed : <%= rating_for @car, 'speed', star_path: true %>
```

To just change one of the star images choose from these options (star_on, star_off, star_half)

6- To add the cancel button to the left, or right of the stars use **(default is false)**
```erb
Speed : <%= rating_for @car, 'speed', cancel: true %>
```
7- To change the place of the cancel button (left, or right) use **(default is left)**
```erb
Speed : <%= rating_for @car, 'speed', cancel_place: left %>
```
8- To change the hint on the cancel button use **(default is "Cancel current rating!" )**
```erb
Speed : <%= rating_for @car, 'speed', cancel_hint: 'Cancel this rating!' %>
```
9- To change the image of the cancel on button use
```erb
Speed : <%= rating_for @car, 'speed', cancel_on: 'cancel-on2.png' %>
```
10- To change the image of the cancel off use
```erb
Speed : <%= rating_for @car, 'speed', cancel_off: 'cancel-off2.png' %>
```
### Other Helpers

You can use the *rating_for_user* helper method to show the star rating for the user.

```erb
Speed : <%= rating_for_user @car, current_user, 'speed', star: 10 %>
```

And you can use the *imdb_style_rating_for* to show a similar to IMDB rating style.

```erb
Speed : <%= rating_for_user @car, current_user, "speed", :star => 10 %>
Speed : <%= imdb_style_rating_for @car, current_user %>
```

## Semantic Versioning

Ratyrate attempts to follow semantic versioning in the format of `x.y.z`, where:

`x` stands for a major version (new features that are not backward-compatible).

`y` stands for a minor version (new features that are backward-compatible).

`z` stands for a patch (bug fixes).

In other words: `Major.Minor.Patch`.

## Feedback
If you find bugs please open a ticket at [https://github.com/muratguzel/letsrate/issues](https://github.com/muratguzel/letsrate/issues)
If you find bugs please open a ticket at [https://github.com/wazery/ratyrate/issues](https://github.com/wazery/ratyrate/issues)
24 changes: 0 additions & 24 deletions letsrate.gemspec

This file was deleted.

Loading