Class: OrganizationsController
- Inherits:
-
ArtfullyOseController
- Object
- ActionController::Base
- ArtfullyOseController
- OrganizationsController
- Defined in:
- app/controllers/organizations_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/organizations_controller.rb', line 33 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 @organization.make_owner(current_user) redirect_to organizations_url, :notice => "#{@organization.name} has been created" else render :new end end |
#edit ⇒ Object
50 51 52 53 |
# File 'app/controllers/organizations_controller.rb', line 50 def edit @organization = Organization.find(params[:id]) :edit, @organization end |
#index ⇒ Object
7 8 9 10 11 12 13 |
# File 'app/controllers/organizations_controller.rb', line 7 def index if current_user.is_in_organization? redirect_to organization_url(current_user.current_organization) else redirect_to new_organization_url end end |
#new ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/organizations_controller.rb', line 20 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 |
#show ⇒ Object
15 16 17 18 |
# File 'app/controllers/organizations_controller.rb', line 15 def show @organization = Organization.find(params[:id]) :view, @organization end |
#update ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/organizations_controller.rb', line 55 def update @organization = Organization.find(params[:id]) :edit, @organization if @organization.update_attributes(params[:organization]) flash[:notice] = "Successfully updated #{@organization.name}." redirect_to @organization else render :show end end |