mardi 28 juillet 2015

How i Can Ensure the current_user by passing it into Scope So that It gives me only Associated Relation Data

In the Code I have Index Method in the NotificationsController

def index  
@notifications = Notification.role_ids_of_user(current_user).notifications_order_by_desc.page(params[:page])
// If i passed nil in place of current_user there should be some Error Handling How it Will done
end

In The Notification.rb

scope :role_ids_of_user, ->(current_user) { where(:role_id => current_user.pluck(:id),:state => "published") }

I want a Error Handling where we can perform for Current_user authentication

Aucun commentaire:

Enregistrer un commentaire