mardi 30 août 2016

ActiveRecord::StatementInvalid in Hr#internal_employee_page

I am learner ruby on rails,I want to join two model(tables). User.rb(users table)

class User < ActiveRecord::Base has_many :offer_letters end

OfferLetter.rb(offer_letter table)

class OfferLetter < ActiveRecord::Base belongs_to :user end

HrController(hr_controller.rb)

class HrController < ApplicationController
    def internal_employee_page
        @employees = OfferLetter.joins(:user).where(:id => :candidate_id)       
end

end

when run my code I got error "Mysql2::Error: Unknown column 'offer_letters.user_id' in 'on clause': SELECT offer_letters.* FROM offer_letters INNER JOIN users ON users.id = offer_letters.user_id WHERE offer_letters.id = NULL"

<div id="job_details">
    <% @employees.each do |emp| %>
       <%= render partial: "hr/employee_details", locals: {emp: emp} %>
    <% end %>               
</div>

Error in this line : <% @employees.each do |emp| %> So tell me where i am wrong

Aucun commentaire:

Enregistrer un commentaire