ruby on rails - How to back to different controller through params -
i have 2 models: restaurants , meals
from /restaurants/2
have
<%= link_to 'new meal', new_meal_path(restaurant_id: @restaurant.id) %>
my meals controller has
@meal = meal.new @meal.restaurant_id = params[:restaurant_id]
i can auto populates restaurant_id
i having problem redirecting /restaurants/2
after have created meal. right redirects meals/:id
.
any ideas on how accomplish this?
in controller can write:
redirect_to restaurant_path(params[:restaurant_id])
ruby-on-rails activerecord ruby-on-rails-4
No comments:
Post a Comment