ruby on rails - Facing issue NoMethodError (undefined method `include' for "56":String): -
i facing issue while writing code
def sim_state sim_employees = simemployee.find(params[:id].include(:employees)) respond_to |format| format.js { render :layout => false, :locals => { :sim_employees => sim_employee } } end end
and in sim_states.js.erb
$('#simstate').text('<%= sim_employee.employees.app_state%>');
so gives me error
nomethoderror (undefined method `include' "56":string):
when use includes gives
undefined method `includes'
please guide me how solve this.
the reason simple
params[:id]
is return string value "56" , includes works activerecord::relation , not string. not able fire query ways.
simemployee.find(params[:id])
this return again result , not relation. try using
simemployee.where(id: params[:id]).includes(:employees).first
this should you.
ps : using includes 1 record same firing 2 independent queries i.e.
@sim_employee = simemployee.find(params[:id]) @emplyess = @sim_employee.employees
Comments
Post a Comment