I think I figured it out.
It was to do with my @student.build_account in the students#show method.
(And as per my original post, I think I had that in my form_for tag).
Because I'm returning to the same page, the foreign key was continually
being 'built'.
My students controller looks likes this:
def show
@student = Student.find(params[:id])
@account = @student.account
if @account.nil?
@account = @student.build_account
end
respond_to do |format|
format.html # show.html.erb
format.json { render json: @student }
end
end
And my accounts controller looks like this:
def create
@student = Student.find(params[:student_id])
@account = @student.create_account(params[:account])
redirect_to student_path(@student)
end
end
And my app/views/students/show.html.erb is attached.
Attachments:
http://www.ruby-forum.com/attachment/7216/show.html.erb
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment