This commit is contained in:
nilsding 2015-01-17 19:53:34 +01:00
parent 4a8005b195
commit 44b4e8721a
1 changed files with 9 additions and 10 deletions

View File

@ -9,22 +9,21 @@ class Ajax::GroupController < ApplicationController
return return
end end
params.require :name begin
params.require :name
rescue ActionController::ParameterMissing
@status = :toolong
@message = "Please give that group a name."
return
end
params.require :user params.require :user
begin begin
target_user = User.find_by_screen_name(params[:user]) target_user = User.find_by_screen_name(params[:user])
group = Group.create! user: current_user, display_name: params[:name] group = Group.create! user: current_user, display_name: params[:name]
rescue ActiveRecord::RecordInvalid rescue ActiveRecord::RecordInvalid
if params[:name].strip.length > 30 @status = :toolong
@status = :toolong @message = "Group name too long (30 characters max.)"
@message = "Group name too long (30 characters max.)"
elsif params[:name].strip.length == 0
@status = :noname
@message = "Please enter a group name."
else
@message = "???"
end
return return
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
@status = :notfound @status = :notfound