Reputation: 325
In Rails, I'm attempting to create a notification system where notifications will be created automatically when certain controller actions are called. I have the following 'create' action in the notifications controller:
def create
@notification = Notification.new(notification_params)
@notification.save
end
I need to call this action from other controller actions, and pass different parameter values to it depending on which controller action calls it. After creating the new notification, I need to continue running code in the controller action that calls it.
Is this possible?
Upvotes: 0
Views: 1500
Reputation: 4386
Move this method to application_controller.rb and allow to pass params to it.
Then you'll be able to call it from any controller method
Upvotes: 1