mardi 30 août 2016

When I joined multiple tables in ruby on rails I got Error : "uninitialized constant OfferLetter::Users"

I am new in ruby on rails,I want to joined multiple tables and extract data and print.I am posting my code...

this is my hr_controller.rb

@employees = OfferLetter.joins(:users, :user_details, :clients)

these are models "user.rb"

class User < ActiveRecord::Base has_many :offer_letter  end

"offer_letter.rb"

class OfferLetter < ActiveRecord::Base  belongs_to :users end

"client,rb"

class Client < ActiveRecord::Base belongs_to :user end

"user_details.rb"

class UserDetail < ActiveRecord::Base belongs_to :user end

here

  • "users table (id, email, first_name, last_name)"
  • "user_details table (user_id, contact_number, gender)"
  • "clients table (user_id,company_name)"
  • "offer_letters(candidate_id,client_id,created_by_id,ctc,cliend_address)"
  • here (id = user_id) in user and user_details and clients
  • (user_id = client_id) in clients and offer_letter
  • (candidate_id = id, created_by_id = id) in users and offerletter tables.
  • **I want to print first_name, last_name, contact_number, gender, ctc, cliend_address, compnay_name etc **

Aucun commentaire:

Enregistrer un commentaire