This commit is contained in:
Yuki 2015-05-09 05:01:31 +05:30
parent 61fdaf6742
commit 05ca42c819
10 changed files with 78 additions and 2 deletions

View File

@ -1,4 +1,11 @@
class Ajax::AnswerController < ApplicationController
rescue_from(ActionController::ParameterMissing) do |titanic_param|
@status = :parameter_error
@message = "#{titanic_param.param.capitalize} is required"
@success = false
render partial: "ajax/shared/status"
end
def create
params.require :id
params.require :answer
@ -27,6 +34,14 @@ class Ajax::AnswerController < ApplicationController
end
end
# this should never trigger because empty params throw ParameterMissing
unless params[:answer].length > 0
@status = :peter_dinklage
@message = "Answer is too short"
@success = false
return
end
answer = nil
begin

View File

@ -1,4 +1,11 @@
class Ajax::CommentController < ApplicationController
rescue_from(ActionController::ParameterMissing) do |param_miss_ex|
@status = :parameter_error
@message = "#{param_miss_ex.param.capitalize} is required"
@success = false
render partial: "ajax/shared/status"
end
def create
params.require :answer
params.require :comment

View File

@ -1,4 +1,11 @@
class Ajax::FriendController < ApplicationController
rescue_from(ActionController::ParameterMissing) do |param_miss_ex|
@status = :parameter_error
@message = "#{param_miss_ex.param.capitalize} is required"
@success = false
render partial: "ajax/shared/status"
end
def create
params.require :screen_name

View File

@ -1,4 +1,11 @@
class Ajax::GroupController < ApplicationController
rescue_from(ActionController::ParameterMissing) do |param_miss_ex|
@status = :parameter_error
@message = "#{param_miss_ex.param.capitalize} is required"
@success = false
render partial: "ajax/shared/status"
end
def create
@status = :err
@success = false
@ -101,7 +108,7 @@ class Ajax::GroupController < ApplicationController
@checked = false
@message = "Successfully removed user from group."
end
@status = :okay
@success = true
end

View File

@ -1,4 +1,11 @@
class Ajax::InboxController < ApplicationController
rescue_from(ActionController::ParameterMissing) do |param_miss_ex|
@status = :parameter_error
@message = "#{param_miss_ex.param.capitalize} is required"
@success = false
render partial: "ajax/shared/status"
end
def create
unless user_signed_in?
@status = :noauth

View File

@ -1,5 +1,11 @@
class Ajax::ModerationController < ApplicationController
rescue_from(ActionController::ParameterMissing) do |param_miss_ex|
@status = :parameter_error
@message = "#{param_miss_ex.param.capitalize} is required"
@success = false
render partial: "ajax/shared/status"
end
def vote
params.require :id
params.require :upvote

View File

@ -1,6 +1,13 @@
class Ajax::QuestionController < ApplicationController
include MarkdownHelper
rescue_from(ActionController::ParameterMissing) do |param_miss_ex|
@status = :parameter_error
@message = "#{param_miss_ex.param.capitalize} is required"
@success = false
render partial: "ajax/shared/status"
end
def destroy
params.require :question

View File

@ -1,4 +1,11 @@
class Ajax::ReportController < ApplicationController
rescue_from(ActionController::ParameterMissing) do |param_miss_ex|
@status = :parameter_error
@message = "#{param_miss_ex.param.capitalize} is required"
@success = false
render partial: "ajax/shared/status"
end
def create
params.require :id
params.require :type

View File

@ -1,4 +1,11 @@
class Ajax::SmileController < ApplicationController
rescue_from(ActionController::ParameterMissing) do |param_miss_ex|
@status = :parameter_error
@message = "#{param_miss_ex.param.capitalize} is required"
@success = false
render partial: "ajax/shared/status"
end
def create
params.require :id

View File

@ -1,5 +1,11 @@
class Ajax::SubscriptionController < ApplicationController
before_filter :authenticate_user!
rescue_from(ActionController::ParameterMissing) do |param_miss_ex|
@status = :parameter_error
@message = "#{param_miss_ex.param.capitalize} is required"
@success = false
render partial: "ajax/shared/status"
end
def subscribe
params.require :answer