I have the project organized in this way: User is the main resource, each user has one profile and each profile has one location as following:
resources :users do
resource :profile, :controller => "profiles" do
resource :location
end
Now I have to build a form for insert all the profile information but the location information as well (address etc).
If I write the following code, it doesn’t take care about the location.
<%= form_for(@profile, :url=>{:action=>'update'}, :html => {:multipart => true}) do |f| %>
Do someone have some suggestion for this situation ?
Tnx
If you want to access different models within the same form you can use
accepts_nested_attributes_for. Here is a great screencast about the topic: http://railscasts.com/episodes/196-nested-model-form-part-1Your code should something like this.
In your view: