suggested changes

This commit is contained in:
shlok007 2017-06-05 11:56:47 +05:30
parent 8edf896d86
commit e0d8e85808
11 changed files with 51 additions and 81 deletions

View file

@ -6,6 +6,33 @@ module Admin
@organizations = Organization.all
end
def create
@organization = Organization.new(organization_params)
if @organization.save
redirect_to admin_organizations_path,
notice: 'Organization successfully created'
else
redirect_to new_admin_organization_path,
error: @organization.errors.full_messages.join(', ')
end
end
def new
@organization = Organization.new
end
def edit; end
def update
if @organization.update_attributes(organization_params)
redirect_to admin_organizations_path,
notice: 'Organization successfully updated'
else
redirect_to edit_admin_organization_path(@organization),
error: @organization.errors.full_messages.join(', ')
end
end
def destroy
if @organization.destroy
redirect_to admin_organizations_path,
@ -15,5 +42,11 @@ module Admin
error: 'Organization cannot be destroyed'
end
end
private
def organization_params
params.require(:organization).permit(:name, :description, :picture)
end
end
end