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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:00:56+00:00 2026-05-26T00:00:56+00:00

I am a Java developer I’ve been learning Rails for the past few days.

  • 0

I am a Java developer I’ve been learning Rails for the past few days. I have a Java EE application (Uses Hibernate for ORM) that I am trying to port to Rails. I have used scaffolding to generate a few of my models. But I have other models which contain references to other models. How do I define the relations? Can I scaffold that as well?

Here is an example for what I am trying to do.

public class Engine {
    private int valves;
    private int capacity;
    private int rpm;
}

I can scaffold the Engine class in ruby just by doing the following:

rails generate scaffold Engine valves:integer capacity:integer rpm:integer

Here is the tricky part for me:

public class Car {
    private Engine engine;
}

How do I scaffold the Car class in Ruby?

  • 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-26T00:00:57+00:00Added an answer on May 26, 2026 at 12:00 am

    If I understand correctly you are looking for associations. Here’s a great guide
    that you should read. The thing to understand here is that you define in your models how the they relate to each other with a series of methods described in that guide.

    Here is what I would suggest you do:

    rails generate scaffold Car <db columns>
    rails generate model Engine valves:integer capacity:integer rpm:integer car_id:integer
    

    In your two models:

    class Car < ActiveRecord::Base
      has_one :engine
    end 
    
    class Engine < ActiveRecord::Base
      belongs_to :car
    end
    

    You can actually generate scaffold for both models…that will create controller and views. But in this case it might make sense to add

    accepts_nested_attribues_for :engine
    

    to your Car model instead. This will allow you to manage the manipulation of the Engine model from the controller and views of the Car model.

    At any rate, I hope this helps you start to find what you need.

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

Sidebar

Related Questions

I've been a java developer for a couple years and have heard that you
Being a Java developer in an agile development cycle, I have learnt that it
My background is primarily as a Java Developer, but lately I have been doing
I am relatively new Java developer that's been thrown in the deep end, my
Hi I am a java developer and these days I have also started working
I'm a Java developer and I have a question about automating a task I've
I've been a Java developer for many years but never had to deal too
I've been a java developer for most of my career, and developed and maintained
As a Java developer I have the following C++ question. If I have objects
I'm a Java Developer wich is learning VB.net for a small project. While coding

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.