Reputation: 20222
Within the controller of currency
, I want to redirect to the show method of prediction
. How can I do this?
def update
respond_to do |format|
if @currency.update(currency_params)
prediction = @currency.neural_network.predict
###redirect to prediction's controller, show method
###???
else
format.html { render :edit }
format.json { render json: @currency.errors, status: :unprocessable_entity }
end
end
end
Upvotes: 2
Views: 817
Reputation: 3111
You can just do redirect_to prediction
Rails will automatically resolve path for the model.
Upvotes: 3
Reputation: 1359
simply add redirect_to prediction
Doing a redirect_to a specific object goes to the show page for that object. Rails knows that prediction
is an active record object, so it interprets that as knowing you want to go to the show page for the object.
Here's the docs for redirect_to
redirect_to(options = {}, response_status = {}) public
Redirects the browser to the target specified in options.
Upvotes: 2