Reputation: 2471
My controller has before action event which check for some parameter based on the redirects to the method
before_action :call_method
def call_method
redirect_to action: process_it, status: 302, params: request.query_parameters and return if params[:navigate]
end
def process_it
render json: {success:'activity recorded'} and return
end
Getting error Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return"
Wanted this {success:'activity recorded'} to be printed
What wrong i am doing here
Upvotes: 0
Views: 622
Reputation: 18504
redirect_to action: process_it ...
- try action name symbol :process_it
instead of calling the method
Upvotes: 0
Reputation: 941
Because you call before_action for every request, also for process_it
. Add except section to before_action
:
before_action :call_method, except: :process_it
Upvotes: 0