Create restful invites controller and ajaxified the workflow.
This commit is contained in:
parent
5cf75ee32a
commit
178fba7b30
11 changed files with 89 additions and 52 deletions
|
|
@ -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
|
||||
26
app/controllers/invites_controller.rb
Normal file
26
app/controllers/invites_controller.rb
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue