0

Models :

Names - belongs_to People
People - has_many names

View:

= form_for @people do |f|
  .blkfr
    = f.fields_for :names do |f_name|
        = f_name.text_field :name

Controller:

# People controller
def update
  #find people
  if @people.update_attributes(params[:people])
    flash[:notice] = "Successfully updated people"
    respond_with @people
  else
    flash[:alert] = "There was an error updating people"
    respond_with @people
  end
end

Error:

Template is missing

Missing template people/edit, application/edit blah blah

I do not have a template for the people's edit method. The route I'm currently hitting is:

.../people/1/names

My question is how do I tell rails to jump back to the same view (names index page), but return the errors for the @people object without receiving that error?

1 Answer 1

1

If you don't have edit template, then specify which template you want to render in your controller.

:render => :index
Sign up to request clarification or add additional context in comments.

2 Comments

That will render the people's index, and not the names index.
you can render any template that is in your application :render => 'people/names/index'

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.