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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:27:43+00:00 2026-05-30T12:27:43+00:00

I have two tables salary_structures and payheads. Below are my table structures: create_table payheads,

  • 0

I have two tables salary_structures and payheads. Below are my table structures:

create_table "payheads", :force => true do |t|
    t.integer  "company_id",             :null => false
    t.integer  "defined_by",             :null => false
    t.string   "payhead_type"
    t.string   "payhead_name"
    t.string   "under"
    t.string   "affect_net_salary"
    t.string   "name_appear_in_payslip"
    t.string   "use_of_gratuity"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

and:

create_table "salary_structures", :force => true do |t|
    t.integer  "company_id",                                                          :null => false
    t.integer  "for_employee"
    t.integer  "created_by"
    t.date     "effective_from_date"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "payhead_id"
    t.decimal  "amount",              :precision => 18, :scale => 2, :default => 0.0
  end

As per my table structure i have payhead_id in my salary_structures table and in my payheads table i have four payheads (basic, Pf etc.). Now when a admin want to define salary_structure of an employee he has to fix amount for every payhead, as per my design i want to save all payheads for an employee for a single salary_structure at once.But here is the problem is for one salary_structure id how can i save more than one payhead’s. Below are my view form:

<%= form_for(@salary_structure) do |f| %>
   <%= render 'shared/form_error', :object => @salary_structure %>

        <div class="field">
             <%= f.label :for_employee, :class => "required" %><br />
             <%= collection_select(:salary_structure, :for_employee, @users, :id, :first_name,:autofocus =>"autofocus", :prompt => true) %>
          </div>

     <div class="column width3">
            <div class="field">
             <%= f.label :effective_from_date, :class => "required" %><br />
             <%= f.text_field :effective_from_date %>
          </div>
     </div> 
     <div class="column width6 first">
      <table  class=" display stylized full" id="salary_structure_report" style="">
         <thead>
            <tr>
             <th width="80%"><label class="required">Pay Head</label></th>
             <th width = "20%"><label class="required">Amount</label></th>
            </tr>
         </thead>
             <tbody>
                <% for ph in @payheads %>
                  <tr>
                    <td width = "80%">
                        <%= f.hidden_field "payhead_id", ph.id %>
                        <%= ph.payhead_name %> </td>
                    <td width = "20%" ><%= f.text_field :amount %></td>
                  </tr>
                <% end %>
                </tbody>
                <tfoot>
                  <tr>
                   <td class="ta-right" width = "80%">Total</td>
                   <td class="ta-left" width = "20%"><span class="WebRupee">Rs</span><span id = "total">00.00</span></td>
                  </tr>
                 </tfoot>
      </table>
   </div><br />
       <div class = "column width3 first">


              <button type="submit" class="btn btn-green big"><img src="/images/add.png" class="icon" /> Save</button>&nbsp;

            <%= link_to 'Cancel', salary_structures_path, :class=>"btn btn-gray bg"%>
       </div>
   </div>  
<% end %>

When i tried to save it normally, it does not save payhead id in salary_structures table
, should i have to do something in models. Any help,would be apologize thanks in advance.

  • 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-30T12:27:45+00:00Added an answer on May 30, 2026 at 12:27 pm

    Hi friends i have found new way to solve it by using an other table named “line_item” and used a “.build” in my controller and it some how working. In my form i have used nested form.

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

Sidebar

Related Questions

I have two tables, like these: Table People: VARCHAR Name INTEGER Age Table Message
I have two tables: Table 1: ID, PersonCode, Name, Table 2: ID, Table1ID, Location,
I have two tables with this structure: Table one: ID Description Table two: ID
I have two tables: one table (okay, it's a view), vComputer, lists many computers
I have two tables in my MySQL database (table1 and table 2). I want
I have two tables, when I check a item in first table it adds
I have two tables with identical schemas and composite keys, table a and table
Suppose i have two tables declare @emp table ( EmpID int, EmpName varchar(10) )
Have two tables with a linking table between them. USERS +-------+---------+ | userID| Username|
I have two tables as below: tbl_test OFID bigint Offer_Text text OFID Offer_Text -------

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.