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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:09:17+00:00 2026-06-12T05:09:17+00:00

I have 2 models (Paygrade and Empsal) for 2 controllers (paygrades and empsals) Here

  • 0

I have 2 models (Paygrade and Empsal) for 2 controllers (paygrades and empsals)
Here in the form of empsals in view (_form.html.erb)

# PayGrade <%= f.collection_select :pay_grade, Paygrade.all, :id, :title,  
# :prompt => 'Select Paygrade' %>
PayGrade <%= f.collection_select :paygrade, Paygrade.all, :id, :title,  
                :prompt => 'Select Paygrade' %>

Model of Empsal

class Empsal
  include Mongoid::Document
  # field :pay_grade, type: String
  belongs_to :paygrade
  field :salary_component, type: String
  field :pay_frequency, type: String
  field :currency, type: String
  field :amount, type: String
  field :comments, type: String

end

Model of Paygrade

class Paygrade
  include Mongoid::Document
  has_many :empsals # +++++ added
  validates_presence_of :title
  field :title, type: String

end

I want to make the association such that it will save id of paygrade in Empsal for field pay_grade.
But shows the related name of id in view.html.erb
<% empsal.pay_grade %>
what association should be done in model of (Paygrade and Empsal) to get the required output?

  • 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-06-12T05:09:18+00:00Added an answer on June 12, 2026 at 5:09 am
    class Empsal
      include Mongoid::Document
      belongs_to :paygrade
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have models A and B. A has_many B. In the edit view for
I want to have one model & view that is served by multiple controllers
I have models A,B,C,D, etc. I have my usual controllers/views/helpers for each of these
I have models like this: class Vendor(models.Model): title = models.CharField() class Product(models.Model): ... vendor
I have models Product and Category . Category can have many products. ( Product
I have models like this: class IdfPracownicy(models.Model): nazwa = models.CharField(max_length=100) class IdfPracaOpinie(models.Model): nazwa =
I have that situation: I have models Item, Region and Country. class Item(models.Model): name
So, say I have models like this: class Foo(Model): name = CharField(max_length=200) def latest_comment(self):
I use flask with flask-peewee and wtfpeewee. So, I have models like that: class
I have two models, Listing and Invitation, associated with has_and_belongs_to_many. I am looking at

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.