introduce Enum

This commit is contained in:
Gosha Arinich
2013-03-01 15:07:44 +03:00
parent 0c8c41b131
commit 0c99dea153
45 changed files with 242 additions and 216 deletions

View File

@ -21,7 +21,7 @@ join (
limit 100
"
sql.where2 "post_action_type_id in (:flag_types)", flag_types: PostActionType.FlagTypes
sql.where2 "post_action_type_id in (:flag_types)", flag_types: PostActionType.flag_types.values
# it may make sense to add a view that shows flags on deleted posts,
@ -62,7 +62,7 @@ limit 100
from post_actions a
/*where*/
"
sql.where("post_action_type_id in (:flag_types)", flag_types: PostActionType.FlagTypes)
sql.where("post_action_type_id in (:flag_types)", flag_types: PostActionType.flag_types.values)
sql.where("post_id in (:posts)", posts: posts.map{|p| p["id"].to_i})
if params[:filter] == 'old'

View File

@ -8,7 +8,7 @@ class PostActionsController < ApplicationController
def create
id = params[:post_action_type_id].to_i
if action = PostActionType.where(id: id).first
guardian.ensure_post_can_act!(@post, PostActionType.Types.invert[id])
guardian.ensure_post_can_act!(@post, PostActionType.types[id])
post_action = PostAction.act(current_user, @post, action.id, params[:message])

View File

@ -134,9 +134,9 @@ class PostsController < ApplicationController
post = find_post_from_params
if current_user
if params[:bookmarked] == "true"
PostAction.act(current_user, post, PostActionType.Types[:bookmark])
PostAction.act(current_user, post, PostActionType.types[:bookmark])
else
PostAction.remove_act(current_user, post, PostActionType.Types[:bookmark])
PostAction.remove_act(current_user, post, PostActionType.types[:bookmark])
end
end
render :nothing => true