Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class VectorsController < ApplicationController
- respond_to :html, :js
- def show
- @vector = Vector.find(params[:id])
- @vector.increment!(:popularity)
- end
- def index
- respond_to do |format|
- format.js do
- @tab_name = params[:tab]
- if @tab_name == "popular"
- @vectors = Vector.popular.page params[:page]
- else
- @vectors = Vector.recent.page params[:page]
- end
- render "shared/vectors_list"
- end
- format.html do
- @vectors = Vector.recent.page params[:page]
- @popular_vectors = Vector.popular.page params[:page]
- render "shared/vectors_list"
- end
- end
- end
- def free_vectors
- @simple_header = "Free vectors"
- respond_to do |format|
- format.js do
- @tab_name = params[:tab]
- if @tab_name == "popular"
- @vectors = Vector.popular.free.page params[:page]
- else
- @vectors = Vector.recent.free.page params[:page]
- end
- render "shared/vectors_list"
- end
- format.html do
- @vectors = Vector.recent.free.page params[:page]
- @popular_vectors = Vector.popular.free.page params[:page]
- render "shared/vectors_list"
- end
- end
- end
- def free_download
- user = User.get_by_email(params[:free_download][:email])
- vector = Vector.free.find(params[:vector_id])
- order = Order.create(user_id: user.id)
- cart = Cart.create(order_id: order.id)
- LineItem.create(cart_id: cart.id, vector_id: vector.id, licence_type: "free")
- cart.send_to_user
- flash[:notice] = "All is OK!"
- redirect_to root_path
- end
- def similar_vectors
- @simple_header = "Similar vectors"
- @vector = Vector.find(params[:vector_id])
- respond_to do |format|
- format.js do
- @tab_name = params[:tab]
- if @tab_name == "popular"
- @vectors = @vector.similar_vectors.popular.page params[:page]
- else
- @vectors = @vector.similar_vectors.recent.page params[:page]
- end
- render "shared/vectors_list"
- end
- format.html do
- @vectors = @vector.similar_vectors.recent.page params[:page]
- @popular_vectors = @vector.similar_vectors.popular.page params[:page]
- render "shared/vectors_list"
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement