Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4320894
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:41:01+00:00 2026-05-21T08:41:01+00:00

I have the project organized in this way: User is the main resource, each

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T08:41:01+00:00Added an answer on May 21, 2026 at 8:41 am

    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-1

    Your code should something like this.

    #profile.rb
    
    accepts_nested_attributes_for :location
    

    In your view:

    <%= form_for(@profile, :url=>{:action=>'update'}, :html => {:multipart => true}) do |f| %>
       <%= f.fields_for :location do |l| %>
         //location fields here, for example:
         <%=l.text_field :city %>
       <% end %>
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project organized as follows: include/ src/ share/myprogram/ where share/myprogram/ contains resources.
I have a C project where all code is organized in *.c / *.h
I have a bunch of HTML resources in my app organized in a hierarchy
This is a high-level project organization question. What is the proper way to organize
I prefer to have one workspace and put all my projects into this one
I have a django project with 2 apps like this: ## tags app, models.py
I have a .Net project called: Whatever.Web.UI: I use this project to put all
I have a WPF application (KaleidoscopeApplication) organized as follows: Solution (6 projects) Cryptography (DLL)
I have project that I'm working on that is going to require a webserver.
I have project Emle in Launchpad . I set it to import from emle.svn.sourceforge.net

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.