Might be a silly one but is it still possible to render an action from another controller in Rails 4?
Like this in UsersController:
def new
@person = User.new
render 'schools/create_person'
end
For some reason it keeps rendering the new.html.erb instead of desired schools/create_person.html.erb
It did not clear me what do you want
but I can suggest one way if you want to render the view
create a partial view (_create_person.html.erb) which are common for both users
and schools
and then
in users
folder new.html.erb
<%= render partial: "schools/create_person" %>
better you can make the partial view in shared folder in your views folder and render it
If you want to redirect
redirect_to create_person_schools_url
#depends on your route define
Check your routes and see if you have the method create_person in schools routes. If positive try redirect_to :
redirect new_school_person_path
with new_school_person_path
as the route to that method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.