add intro route shortcut, optimize Favorite.remove
This commit is contained in:
@@ -34,7 +34,7 @@ class Favorite < ActiveRecord::Base
|
||||
User.where(:id => user.id).select("id").lock("FOR UPDATE NOWAIT").first
|
||||
|
||||
return unless Favorite.for_user(user.id).where(:user_id => user.id, :post_id => post.id).exists?
|
||||
Favorite.for_user(user.id).where(post_id: post.id).delete_all
|
||||
Favorite.destroy_all(user_id: user.id, post_id: post.id)
|
||||
updates = "fav_count = fav_count - 1"
|
||||
updates = "#{updates}, score = score - 1" if user.is_gold?
|
||||
Post.where(:id => post.id).update_all(updates)
|
||||
|
||||
@@ -411,5 +411,7 @@ Rails.application.routes.draw do
|
||||
get "/static/name_change" => "static#name_change", :as => "name_change"
|
||||
get "/meta_searches/tags" => "meta_searches#tags", :as => "meta_searches_tags"
|
||||
|
||||
get "/intro" => redirect("/explore/posts/intro")
|
||||
|
||||
root :to => "posts#index"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user