We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Getting error while clicking the 'reviews' in the spree admin panel.
index.html.erb
` <% content_for :page_title do %> <%= Spree.t('reviews') %> <% end %> <% render 'spree/admin/shared/product_sub_menu' %> <% content_for :table_filter_title do %> <%= Spree.t('search') %> <% end %> <% content_for :table_filter do %> <div data-hook="admin_reviews_index_search"> <%= search_form_for [:admin, @search] do |f| %> <div class="alpha three columns"> <div class="field"> <%= label_tag nil, Spree.t(:user) %><br /> <%= f.text_field :name_cont, :size => 25 %> </div> </div> <div class="seven columns"> <div class="field"> <%= label_tag nil, Spree.t(:title) -%><br/> <%= f.text_field :title_cont, :size => 25 -%> </div> </div> <div class="four columns"> <div class="field"> <%= label_tag nil, Spree.t(:review) -%><br/> <%= f.text_field :review_cont, :size => 25 -%> </div> </div> <div class="two columns omega"> <div class="field"> <%= label_tag nil, Spree.t(:approval_status)-%><br/> <%= f.select :approved_eq, [[Spree.t('all'), nil], [Spree.t('approved_reviews'), true], [Spree.t('unapproved_reviews'), false]] -%> </div> </div> <div class="clear"></div> <div class="form-buttons actions filter-actions" data-hook="admin_reviews_index_search_buttons"> <%= button Spree.t(:search), 'icon-search' %> </div> <%- end -%> </div> <%- end -%> <pre> <%= Spree::Review.inspect %> <%= params[:q][:title_cont].inspect %> <% if params[:q][:title_cont].present? == true %> <%= @reviews.inspect %> <%end%> </pre> <% if @reviews.nil? %> <table class="index"> <colgroup> <col style="width: 25%;"> <col style="width: 10%;"> <col style="width: 10%;"> <col style="width: 20%;"> <col style="width: 15%;"> <col style="width: 17%;"> </colgroup> <thead> <tr> <th><%= Spree.t('product') %></th> <th><%= Spree::Review.human_attribute_name(:rating) %></th> <th><%= Spree.t('feedback') %></th> <th><%= Spree::Review.human_attribute_name(:user) %></th> <th><%= Spree::Review.human_attribute_name(:created_at) %></th> </tr> </thead> <tbody> <%- @reviews.each do |review| -%> <tr id="<%= dom_id review %>"> <td> <% if review.product %> <%= link_to review.product.name, product_path(review.product) %> <% end %> </td> <td class="align-center"> <%= txt_stars(review.rating) %> </td> <td class="align-center"> <%= link_to "(#{review.feedback_stars}/#{review.feedback_reviews.size})", admin_review_feedback_reviews_path(review) %> </td> <td class="align-center"> <%= review.user_id ? link_to(review.user.try(:email), [:admin, review.user]) : Spree.t(:anonymous) %></p> <p><%= Spree::Review.human_attribute_name(:ip_address) %>: <%= review.ip_address ? link_to(review.ip_address, "http://whois.domaintools.com/#{review.ip_address}") : '-' %></p> </td> <td class="align-center"> <%= l review.created_at, :format => :short %> </td> <td class="actions"> <%= link_to_with_icon 'check', Spree.t('approve'), approve_admin_review_url(review), :no_text => true, class: 'approve' unless review.approved %> <%= link_to_edit review, :no_text => true, :class => 'edit' %> <%= link_to_delete review, :no_text => true %> </td> </tr> <% end %> </tbody> </table> <% else %> <div class="no-objects-found"> <%= Spree.t(:no_results) %> </div> <% end %>
` Model - review.rb
`class Spree::Review < ActiveRecord::Base belongs_to :product, touch: true belongs_to :user, :class_name => Spree.user_class.to_s has_many :feedback_reviews after_save :recalculate_product_rating, :if => :approved? after_destroy :recalculate_product_rating validates :name, presence: true validates :review, presence: true validates :rating, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: 5, message: Spree.t('you_must_enter_value_for_rating') } default_scope { order("spree_reviews.created_at DESC") } scope :localized, ->(lc) { where('spree_reviews.locale = ?', lc) } scope :most_recent_first, -> { order('spree_reviews.created_at DESC') } scope :oldest_first, -> { reorder('spree_reviews.created_at ASC') } scope :preview, -> { limit(Spree::Reviews::Config[:preview_size]).oldest_first } scope :approved, -> { where(approved: true) } scope :not_approved, -> { where(approved: false) } scope :default_approval_filter, -> { Spree::Reviews::Config[:include_unapproved_reviews] ? all : approved } def feedback_stars return 0 if feedback_reviews.size <= 0 ((feedback_reviews.sum(:rating) / feedback_reviews.size) + 0.5).floor end def set_search @search=Product.search(params[:q]) end def recalculate_product_rating self.product.recalculate_rating if product.present? end end
`
reviews_controller.rb:
` class Spree::Admin::ReviewsController < Spree::Admin::ResourceController helper Spree::ReviewsHelper def index @reviews = collection end def approve r = Spree::Review.find(params[:id]) if r.update_attribute(:approved, true) flash[:notice] = Spree.t("info_approve_review") else flash[:error] = Spree.t("error_approve_review") end redirect_to admin_reviews_path end def edit if @review.product.nil? flash[:error] = Spree.t("error_no_product") redirect_to admin_reviews_path and return end end private def collection params[:q] ||= {} @search = Spree::Review.ransack(params[:q]) @collection = @search.result.includes([:product, :user, :feedback_reviews]).page(params[:page]).per(params[:per_page]) end end`
Gemfile:
`source 'https://rubygems.org' gem 'rails', '>= 4.0.8' # Use sqlite3 as the database for Active Record gem 'mysql2', '~> 0.3.18' # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.2' gem 'compass-rails' # Provides the generator settings required for Rails to use Haml gem 'haml-rails' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .js.coffee assets and views gem 'coffee-rails', '~> 4.0.0' gem 'jquery-rails' gem 'bootstrap-sass', '~> 3.1.1' gem 'jbuilder', '~> 1.2' group :doc do gem 'sdoc', require: false end gem 'braintree' gem 'spree', github: 'spree/spree', branch: '2-2-stable' gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-2-stable' gem 'spree_gateway', github: 'spree/spree_gateway', branch: '2-2-stable' gem 'spree_editor', github: 'spree-contrib/spree_editor', branch: '2-2-stable' gem 'spree_blogging_spree', github: 'stefansenk/spree-blogging-spree', branch: '2-2-stable' gem 'spree_paypal_express', github: 'spree-contrib/better_spree_paypal_express', branch: '2-2-stable' gem 'spree_reviews', github: 'spree-contrib/spree_reviews', branch: '2-2-stable' gem 'spree_variant_options', git: 'git://github.com/AgilTec/spree_variant_options.git', branch: '2-2-stable' gem 'social-share-button' gem 'instagram', :git => 'git://github.com/Instagram/instagram-ruby-gem.git' gem 'will_paginate','~> 3.1.5' gem 'capistrano', '~> 3.2.0' gem 'capistrano-rails', '~> 1.1' gem 'capistrano-rvm' gem 'capistrano-bundler', '~> 1.1.2' gem 'therubyracer' gem 'mail_view', '~> 2.0.4' group :production do gem 'passenger' end # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use unicorn as the app server # gem 'unicorn' # Use Capistrano for deployment # gem 'capistrano', group: :development # Use debugger # gem 'debugger', group: [:development, :test]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Getting error while clicking the 'reviews' in the spree admin panel.
index.html.erb
`
Model - review.rb
`
reviews_controller.rb:
Gemfile:
`
The text was updated successfully, but these errors were encountered: