Skip to content
This repository has been archived by the owner on Feb 5, 2021. It is now read-only.

rails4 fixes #99

Open
wants to merge 3 commits into
base: rails3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ begin

Jeweler::Tasks.new do |spec|
spec.name = "ajaxful_rating"
spec.version = "3.0.0.beta6"
spec.version = "3.0.0.beta8"
spec.summary = "Provides a simple way to add rating functionality to your application."
spec.description = "Provides a simple way to add rating functionality to your application."
spec.homepage = "http://github.com/edgarjs/ajaxful-rating"
Expand Down
14 changes: 7 additions & 7 deletions ajaxful_rating.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
s.name = %q{ajaxful_rating}
s.version = "3.0.0.beta6"
s.name = "ajaxful_rating"
s.version = "3.0.0.beta8"

s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["Edgar J. Suarez", "Denis Odorcic"]
s.date = %q{2011-08-23}
s.description = %q{Provides a simple way to add rating functionality to your application.}
s.date = "2012-01-07"
s.description = "Provides a simple way to add rating functionality to your application."
s.email = ["[email protected]", "[email protected]"]
s.extra_rdoc_files = [
"README.textile"
Expand Down Expand Up @@ -45,10 +45,10 @@ Gem::Specification.new do |s|
"test/lib/model_test.rb",
"test/test_helper.rb"
]
s.homepage = %q{http://github.com/edgarjs/ajaxful-rating}
s.homepage = "http://github.com/edgarjs/ajaxful-rating"
s.require_paths = ["lib"]
s.rubygems_version = %q{1.6.2}
s.summary = %q{Provides a simple way to add rating functionality to your application.}
s.rubygems_version = "1.8.10"
s.summary = "Provides a simple way to add rating functionality to your application."

if s.respond_to? :specification_version then
s.specification_version = 3
Expand Down
4 changes: 2 additions & 2 deletions lib/axr/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module Helpers
# current page.
def ajaxful_rating_style
@axr_css ||= CSSBuilder.new
stylesheet_link_tag('ajaxful_rating') +
content_tag(:style, @axr_css.to_css, :type => "text/css")
# stylesheet_link_tag('ajaxful_rating') +
content_tag(:style, @axr_css.to_css, :type => "text/css")
end

# Generates the stars list to submit a rate.
Expand Down
9 changes: 4 additions & 5 deletions lib/axr/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ module ClassMethods
# ajaxful_rateable :stars => 10, :cache_column => :custom_column
# end
def ajaxful_rateable(options = {})
has_many :rates_without_dimension, :as => :rateable, :class_name => 'Rate',
:dependent => :destroy, :conditions => {:dimension => nil}
has_many :rates_without_dimension, -> { where(dimension: nil) }, :as => :rateable, :class_name => 'Rate',
:dependent => :destroy
has_many :raters_without_dimension, :through => :rates_without_dimension, :source => :rater

class << self
Expand All @@ -39,9 +39,8 @@ def axr_config(dimension = nil)

if options[:dimensions].is_a?(Array)
options[:dimensions].each do |dimension|
has_many "#{dimension}_rates", :dependent => :destroy,
:conditions => {:dimension => dimension.to_s}, :class_name => 'Rate', :as => :rateable
has_many "#{dimension}_raters", :through => "#{dimension}_rates", :source => :rater
has_many :"#{dimension}_rates", -> { where(dimension: dimension.to_s) }, :dependent => :destroy, :class_name => 'Rate', :as => :rateable
has_many :"#{dimension}_raters", :through => :"#{dimension}_rates", :source => :rater

axr_config(dimension).update(options)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/axr/stars_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ def ratings_tag
end

def star_tag(value)
already_rated = rateable.rated_by?(user, options[:dimension]) if user
already_rated = rateable.rated_by?(user, options[:dimension]) if user && !rateable.axr_config(options[:dimension])[:allow_update]
css_class = "stars-#{value}"
@css_builder.rule(".ajaxful-rating .#{css_class}", {
:width => "#{(value / rateable.class.max_stars.to_f) * 100}%",
:zIndex => (rateable.class.max_stars + 2 - value).to_s
})

@template.content_tag(:li) do
if !options[:force_static] && (user && options[:current_user] == user && (!already_rated || rateable.axr_config(options[:dimension])[:allow_update]))
if !options[:force_static] && !already_rated && user && options[:current_user] == user
link_star_tag(value, css_class)
else
@template.content_tag(:span, show_value, :class => css_class, :title => i18n(:current))
Expand Down
6 changes: 3 additions & 3 deletions lib/generators/ajaxful_rating/ajaxful_rating_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def create_migration
end

def create_layout
copy_file 'images/star.png', 'public/images/ajaxful_rating/star.png'
copy_file 'images/star_small.png', 'public/images/ajaxful_rating/star_small.png'
copy_file 'style.css', 'public/stylesheets/ajaxful_rating.css'
copy_file 'images/star.png', 'assets/images/ajaxful_rating/star.png'
copy_file 'images/star_small.png', 'assets/images/ajaxful_rating/star_small.png'
copy_file 'style.css', 'assets/stylesheets/ajaxful_rating.css.scss'
end

private
Expand Down
4 changes: 2 additions & 2 deletions lib/generators/ajaxful_rating/templates/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
.ajaxful-rating a:active,
.ajaxful-rating a:focus,
.ajaxful-rating .show-value{
background: url(/images/ajaxful_rating/star.png) left -1000px repeat-x;
background: image-url("ajaxful_rating/star.png") left -1000px repeat-x;
}
.ajaxful-rating{
position: relative;
Expand Down Expand Up @@ -78,7 +78,7 @@ z-index: 2;
.ajaxful-rating.small a:active,
.ajaxful-rating.small a:focus,
.ajaxful-rating.small .show-value{
background-image: url(/images/ajaxful_rating/star_small.png);
background-image: image-url("ajaxful_rating/star_small.png");
line-height: 10px;
height: 10px;
}