Create restful invites controller and ajaxified the workflow.

This commit is contained in:
Benjamin Meichsner 2009-08-02 19:41:09 +02:00
parent 5cf75ee32a
commit 178fba7b30
11 changed files with 89 additions and 52 deletions

View file

@ -1,20 +0,0 @@
class FoodcoopController < ApplicationController
before_filter :authenticate_membership_or_admin
# Invites a new user to join foodsoft in this group.
def invite
@invite = Invite.new
end
# Sends an email
def send_invitation
@invite = Invite.new(:user => @current_user, :group => @group, :email => params[:invite][:email])
if @invite.save
flash[:notice] = format('Es wurde eine Einladung an %s geschickt.', @invite.email)
redirect_to root_path
else
render :action => 'invite'
end
end
end

View file

@ -0,0 +1,26 @@
class InvitesController < ApplicationController
before_filter :authenticate_membership_or_admin, :only => [:new]
#TODO: auhtorize also for create action.
def new
@invite = Invite.new(:user => @current_user, :group => @group)
render :update do |page|
page.replace_html :edit_box, :partial => "new"
page.show :edit_box
end
end
def create
@invite = Invite.new(params[:invite])
render :update do |page|
if @invite.save
page.replace_html :edit_box, :partial => "success"
else
page.replace_html :edit_box, :partial => "new"
end
end
end
end