0

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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.