diff options
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/application_controller.rb | 11 | ||||
| -rw-r--r-- | app/controllers/organisations_controller.rb | 10 | ||||
| -rw-r--r-- | app/controllers/users_controller.rb | 35 |
3 files changed, 56 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ae953a25a..8cde89db0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,4 +1,15 @@ class ApplicationController < ActionController::Base protect_from_forgery before_filter :authenticate_user! + + protected + + def current_organisation + current_user.organisation if current_user + end + helper_method :current_organisation + + def begin_of_association_chain + current_organisation + end end diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb new file mode 100644 index 000000000..daeb41837 --- /dev/null +++ b/app/controllers/organisations_controller.rb @@ -0,0 +1,10 @@ +class OrganisationsController < InheritedResources::Base + respond_to :html + + private + + def resource + @organisation = current_organisation + end +end + diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 000000000..ee9cbcda1 --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,35 @@ +class UsersController < InheritedResources::Base + + def create + Rails.logger.info( "call user_controller.create") + Rails.logger.info( "resource=#{build_resource.inspect}") + Rails.logger.info( "resourc.valid?e=#{build_resource.valid?}") + Rails.logger.info( "resourc.errors=#{build_resource.errors.inspect}") + create! do |success, failure| + success.html { + Rails.logger.info( "success user_controller") + mail = UserMailer.welcome(@user) + mail.deliver + redirect_to organisation_user_path(@user) } + end + end + + def update + update! do |success, failure| + success.html { redirect_to organisation_user_path(@user) } + end + end + + def destroy + destroy! do |success, failure| + success.html { redirect_to organisation_path } + end + end + + protected + + def begin_of_association_chain + current_organisation + end + +end |
