Sha256: 9d0c7c337a1b987efca0c8ccf16bd06b569eeae24b6d17578387721428f18e90

Contents?: true

Size: 761 Bytes

Versions: 4

Compression:

Stored size: 761 Bytes

Contents

module Helpers
  	def seems_rateable_style
  		stylesheet_link_tag "rateable/jRating.jquery"
  	end
  		
  	def rating_for(obj, opts={:dimension => nil, :static => false, :id => nil}) 	  
  	   begin
  			kls = opts[:dimension].nil? ? obj.average : obj.average(opts[:dimension])
  			avg = kls ? kls.avg : 0
  			content_tag :div, "", "data-average" => avg,
  			:id => opts[:id],
        :class => "rateable#{opts[:static] ? " jDisabled" : nil}#{current_user ? nil : " jDisabled"}",
        "data-id" => obj.id, "data-kls" => obj.class.name,
        "data-dimension" => opts[:dimension]      
  		rescue StandardError => error
  			eval "raise 'Rateable object #{obj.inspect} does not exist'"
  		end
  	end
  end

class ActionView::Base
	include Helpers
end	

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
seems_rateable-1.0.6 lib/seems_rateable/helpers.rb
seems_rateable-1.0.5 lib/seems_rateable/helpers.rb
seems_rateable-1.0.4 lib/seems_rateable/helpers.rb
seems_rateable-1.0.3 lib/seems_rateable/helpers.rb