foodsoft/app/controllers/invites_controller.rb

27 lines
610 B
Ruby
Raw Normal View History

class InvitesController < ApplicationController
before_filter :authenticate_membership_or_admin, :only => [:new]
2013-02-04 13:00:34 +01:00
#TODO: authorize also for create action.
def new
@invite = Invite.new(:user => @current_user, :group => @group)
end
def create
@invite = Invite.new(params[:invite])
2012-08-06 12:00:40 +02:00
if @invite.save
Mailer.invite(@invite).deliver
respond_to do |format|
format.html do
2013-02-04 13:00:34 +01:00
redirect_to back_or_default_path, notice: I18n.t('invites.success')
end
format.js { render layout: false }
end
2012-08-06 12:00:40 +02:00
else
render action: :new
end
end
end