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
end
begin
params.require :name
rescue ActionController::ParameterMissing
@status = :toolong
@message = "Please give that group a name."
return
end
params.require :user
begin
target_user = User.find_by_screen_name(params[:user])
group = Group.create! user: current_user, display_name: params[:name]
rescue ActiveRecord::RecordInvalid
if params[:name].strip.length > 30
@status = :toolong
@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
rescue ActiveRecord::RecordNotFound
@status = :notfound