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 6110673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:32:32+00:00 2026-05-23T14:32:32+00:00

I am using RoR 3 to create a new website for myself. I have

  • 0

I am using RoR 3 to create a new website for myself. I have 3 models like so:

Ship model has many ShipClasses
Ship model has many ShipEntries
ShipEntry belongs to Ship
ShipEntry belongs to ShipClass

When I am creating the Ship I generated nested forms for ShipClasses and ShipEntries. The problem I have is when creating a ShipEntry it should have one of the new ShipClasses assigned to it but at the moment when the Ship is created I have to go back in and edit the Ship and assign the ShipClasses to the ShipEntry due to the new ShipClasses not yet having been created in the DB. Is it possible at the creation of the ship to assign the newly created ShipClasses to the ShipEntry?

I hope someone gets what I mean, if you have any trouble understanding this let me know and i’ll try to explain further.

Cheers

Eef

  • 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-23T14:32:33+00:00Added an answer on May 23, 2026 at 2:32 pm

    You can achieve what you want to do with active callbacks.

    You could use something like after_create to link both.

    after_create :link_ship_entry_and_classes
    
    def link_ship_entry_and_classes
      # whatever you need to do here
    end
    

    You can read everything there is to know about AC : http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html

    Hope this helps!

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

Sidebar

Related Questions

I have the following Rake file. Using RoR 2.3.8. desc Create shops sitemap task(:shops
I have code in my model (RoR 3.0.x) that is more or less like
Using Ruby/RoR - The year is a string in the model/view. How do I
I am interested in using/learning RoR in a project where I have to use
I'm building a website based on RoR, and using a third-party gem devise. I
I'm fairly new to RoR I have a controller and within that controller I
I have an old CMS I built using Coldfusion. I would like to get
Just starting to learn Ruby on Rails. I'm using RoR 3. I have read
I am new to ror. I have 2 tables for group (called 'ab') and
ROR Sample Application URL - http://sixrevisions.com/web-development/how-to-create-a-blog-from-scratch-using-ruby-on-rails/ I tried above reference for creating a blog

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.