Sha256: d556e2e1c7a32153c487c440bf4926201749ccfd150a70cce8a513ba6a61d9d5
Contents?: true
Size: 1.73 KB
Versions: 2
Compression:
Stored size: 1.73 KB
Contents
class OrganizationsController < ArtfullyOseController rescue_from CanCan::AccessDenied do |exception| flash[:alert] = exception.message redirect_to root_path end def index if current_user.is_in_organization? redirect_to organization_url(current_user.current_organization) else redirect_to new_organization_url end end def show @organization = Organization.find(params[:id]) authorize! :view, @organization end def new unless current_user.current_organization.new_record? flash[:error] = "You can only join one organization at this time." redirect_to organizations_url end if Organization.all.length > 0 flash[:error] = "There is already an organization created for this installation." end @organization = Organization.new end def create if Organization.all.length > 0 flash[:error] = "There is already an organization created for this installation." redirect_to new_organization_path and return end @organization = Organization.new(params[:organization]) if @organization.save @organization.users << current_user redirect_to organizations_url, :notice => "#{@organization.name} has been created" else render :new end end def edit @organization = Organization.find(params[:id]) authorize! :edit, @organization end def update @organization = Organization.find(params[:id]) authorize! :edit, @organization if @organization.update_attributes(params[:organization]) flash[:notice] = "Successfully updated #{@organization.name}." redirect_to @organization else flash[:error]= "Failed to update #{@organization.name}." render :show end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
artfully_ose-1.0.0.rc4 | app/controllers/organizations_controller.rb |
artfully_ose-1.0.0.rc3 | app/controllers/organizations_controller.rb |