Class: UserNotificationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- UserNotificationsController
- Defined in:
- app/controllers/user_notifications_controller.rb
Instance Method Summary (collapse)
Methods inherited from ApplicationController
Instance Method Details
- (Object) create
9 10 11 12 13 14 15 |
# File 'app/controllers/user_notifications_controller.rb', line 9 def create if current_user.user_notifications.create(params[:user_notification]) redirect_to root_path, notice: t(:message_successfully_sent) else render :new end end |
- (Object) destroy
17 18 19 20 21 22 23 24 |
# File 'app/controllers/user_notifications_controller.rb', line 17 def destroy @user = User.find(params[:user_id]) @user_notification = @user.user_notifications.find(params[:id]) :manage, @user_notification @user_notification.delete @user.save redirect_to notifications_path, notice: t(:notification_successfully_deleted) end |
- (Object) emails
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/user_notifications_controller.rb', line 26 def emails respond_to do |format| format.json { render :json => User.any_of({ name: /#{params[:q]}/i }, { email: /#{params[:q]}/i }) .only(:email,:name) .map{ |user| [ :id =>user.email, :name => user.name + " (#{user.email})" ] } .flatten } end end |
- (Object) new
5 6 7 |
# File 'app/controllers/user_notifications_controller.rb', line 5 def new @user_notification = current_user.user_notifications.build() end |