Commit 8f60b5b4 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Group and Event strong_params

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 16a0a4ae
...@@ -20,7 +20,7 @@ class Admin::GroupsController < Admin::ApplicationController ...@@ -20,7 +20,7 @@ class Admin::GroupsController < Admin::ApplicationController
end end
def create def create
@group = Group.new(params[:group]) @group = Group.new(group_params)
@group.path = @group.name.dup.parameterize if @group.name @group.path = @group.name.dup.parameterize if @group.name
if @group.save if @group.save
...@@ -32,7 +32,7 @@ class Admin::GroupsController < Admin::ApplicationController ...@@ -32,7 +32,7 @@ class Admin::GroupsController < Admin::ApplicationController
end end
def update def update
if @group.update_attributes(params[:group]) if @group.update_attributes(group_params)
redirect_to [:admin, @group], notice: 'Group was successfully updated.' redirect_to [:admin, @group], notice: 'Group was successfully updated.'
else else
render "edit" render "edit"
...@@ -56,4 +56,8 @@ class Admin::GroupsController < Admin::ApplicationController ...@@ -56,4 +56,8 @@ class Admin::GroupsController < Admin::ApplicationController
def group def group
@group = Group.find_by(path: params[:id]) @group = Group.find_by(path: params[:id])
end end
def group_params
params.require(:group).permit(:name, :description, :path, :avatar)
end
end end
...@@ -22,7 +22,7 @@ class GroupsController < ApplicationController ...@@ -22,7 +22,7 @@ class GroupsController < ApplicationController
end end
def create def create
@group = Group.new(params[:group]) @group = Group.new(group_params)
@group.path = @group.name.dup.parameterize if @group.name @group.path = @group.name.dup.parameterize if @group.name
if @group.save if @group.save
...@@ -84,7 +84,7 @@ class GroupsController < ApplicationController ...@@ -84,7 +84,7 @@ class GroupsController < ApplicationController
end end
def update def update
if @group.update_attributes(params[:group]) if @group.update_attributes(group_params)
redirect_to edit_group_path(@group), notice: 'Group was successfully updated.' redirect_to edit_group_path(@group), notice: 'Group was successfully updated.'
else else
render action: "edit" render action: "edit"
...@@ -159,4 +159,8 @@ class GroupsController < ApplicationController ...@@ -159,4 +159,8 @@ class GroupsController < ApplicationController
params[:state] = 'opened' if params[:state].blank? params[:state] = 'opened' if params[:state].blank?
params[:group_id] = @group.id params[:group_id] = @group.id
end end
def group_params
params.require(:group).permit(:name, :description, :path, :avatar)
end
end end
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
# #
class Event < ActiveRecord::Base class Event < ActiveRecord::Base
#attr_accessible :project, :action, :data, :author_id, :project_id,
#:target_id, :target_type
default_scope { where.not(author_id: nil) } default_scope { where.not(author_id: nil) }
CREATED = 1 CREATED = 1
......
...@@ -20,8 +20,6 @@ class Group < Namespace ...@@ -20,8 +20,6 @@ class Group < Namespace
has_many :users_groups, dependent: :destroy has_many :users_groups, dependent: :destroy
has_many :users, through: :users_groups has_many :users, through: :users_groups
#attr_accessible :avatar
validate :avatar_type, if: ->(user) { user.avatar_changed? } validate :avatar_type, if: ->(user) { user.avatar_changed? }
validates :avatar, file_size: { maximum: 100.kilobytes.to_i } validates :avatar, file_size: { maximum: 100.kilobytes.to_i }
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
class Namespace < ActiveRecord::Base class Namespace < ActiveRecord::Base
include Gitlab::ShellAdapter include Gitlab::ShellAdapter
#attr_accessible :name, :description, :path
has_many :projects, dependent: :destroy has_many :projects, dependent: :destroy
belongs_to :owner, class_name: "User" belongs_to :owner, class_name: "User"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment