Class: ReviewsController

Inherits:
Spree::BaseController
  • Object
show all
Defined in:
app/controllers/reviews_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

save if all ok



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/reviews_controller.rb', line 15

def create
  @product = Product.find_by_permalink params[:product_id]
  params[:review][:rating].sub!(/\s*stars/,'') unless params[:review][:rating].blank?

  @review = Review.new :product => @product
  if @review.update_attributes(params[:review]) 
    flash[:notice] = t('review_successfully_submitted')
    redirect_to (product_path(@product))
  else
    # flash[:notice] = 'There was a problem in the submitted review'
    render :action => "new" 
  end
end

#indexObject



4
5
6
7
# File 'app/controllers/reviews_controller.rb', line 4

def index
  @product = Product.find_by_permalink params[:product_id]
  @approved_reviews = Review.approved.find_all_by_product_id(@product.id) 
end

#newObject



9
10
11
12
# File 'app/controllers/reviews_controller.rb', line 9

def new
  @product = Product.find_by_permalink params[:product_id] 
  @review = Review.new :product => @product
end

#termsObject



28
29
# File 'app/controllers/reviews_controller.rb', line 28

def terms
end