I have 2 controller API, A and B on Ruby on rails application. If the parameter passed the validation in controller A, it will redirect to create
action on controller B. If it is not, then continue to run the logic on controller A.
At first, I try using redirect_to
, but since the action is using POST method, it doesn't work. Then I try to use repost
ruby gems, from https://rubygems.org/gems/repost.
I have followed the documentation, but when I test the API, it returns No template found for xxxController#create, rendering head :no_content
. Since it is an API, I think it doesn't need view.
I have tried to add view for that controller, but it ends up rendering the html to the response. Anyone have an idea to make it redirect to other controller? Or any other ways to solve this using other gems maybe?
EDIT I also try to render the html this way:
render html: Repost::Senpai.perform('http://xxx', params: { auth: request.params[:user] }, options: {authenticity_token: :auto, autosubmit: true}).html_safe, status: status
I copy the logic from the gem repo in https://github.com/vergilet/repost/blob/master/lib/repost/extend_controller.rb. But still, the html just rendered to the response. It doesn't redirect to given url