Introduce basic views for organization
organization#index organizaton#new and organization#edit
This commit is contained in:
parent
a06dc84eb0
commit
b1fac33420
5 changed files with 79 additions and 0 deletions
41
app/controllers/organizations_controller.rb
Normal file
41
app/controllers/organizations_controller.rb
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
class OrganizationsController < ApplicationController
|
||||
load_and_authorize_resource :organization
|
||||
|
||||
def index
|
||||
@organizations = Organization.all
|
||||
end
|
||||
|
||||
def create
|
||||
@organization = Organization.new(organization_params)
|
||||
if @organization.save
|
||||
redirect_to organizations_path,
|
||||
notice: 'Organization successfully created'
|
||||
else
|
||||
redirect_to new_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 organizations_path,
|
||||
notice: 'Organization successfully updated'
|
||||
else
|
||||
redirect_to edit_organization_path(@organization),
|
||||
error: @organization.errors.full_messages.join(', ')
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def organization_params
|
||||
params.require(:organization).permit(:name, :description, :picture)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue