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

  • SEARCH
  • Home
  • 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 3282958
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:59:11+00:00 2026-05-17T19:59:11+00:00

I’ve got an organisation database table which holds the following fields: organisationid, organisationname, organisationaddressid,

  • 0

I’ve got an organisation database table which holds the following fields:

organisationid, organisationname, organisationaddressid, mainadminname, mainadminaddressid.

The two address ids are pointers to two records within the address database table. The address database table conatins the following fields:

addressid, addressline1, addressline2, addresstowncity, addresspostcode.

So when I create new organisation I want to capture the following information:

organisationname
organisationaddressline1
organisationaddressline2
organisationaddresstowncity
organisationaddresspostcode
mainadminname
mainadminaddressline1
mainadminaddressline2
mainadminaddresstowncity
mainadminaddresspostcode

And when I save this information I want to create 1 organisation record and two address records.

I’m at a loss on how to do this in ROR!

Any suggestions gratefully recieved.

Thanks for your time

Sniffer

  • 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-17T19:59:12+00:00Added an answer on May 17, 2026 at 7:59 pm

    Not quite standard looking rails column names, so I’m guessing you may be working with a legacy DB, at any rate:

    Assuming that your Organization model was something like this:

    belongs_to :organization_address, :class_name => 'Address', :foreign_key => 'organisationaddressid'
    belongs_to :main_admin_address, :class_name => 'Address', :foreign_key => 'mainadminaddressid'
    
    # See http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html
    # Make the organization accept nested attributes for the addresses
    accepts_nested_attributes_for :organization_address, :main_admin_address
    

    Your form would probably look something like this with fields_for the different addresses:

    <% form_for Organization.new do |f| %>
      <%= f.text_field :name %><br />
      <% fields_for :organization_address do |oaf| %>
        <%= oaf.text_field :addressline1 %><br />
        <%= oaf.text_field :addressline2 %><br />
        ...
      <% end %>
      <%= f.text_field :name %><br />
      <% fields_for :main_admin_address do |maaf| %>
        <%= maaf.text_field :addressline1 %><br />
        <%= maaf.text_field :addressline2 %><br />
        ...
      <% end %>
    <% end %>
    

    After that, in your controller

    @organization = Organization.new(params[:organization])
    @organization.save
    

    Should save the organization model as well as the two address models.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I

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.