rails activerecord metasearch undefined method -


i'm new rails , need should simple problem.

when run code:

@search = user.search(params[:search]) @foundusers = @search.all.paginate :page => params[:page], :per_page => 20 @user = @search.where("users.id = ?", params[:id]) if @user.nil?   @user = @foundusers.first end unless @user.company_id.nil?   @company = company.find(@user.company_id) end 

i following error statement: undefined method `company_id' #

i dont understand because query on database correct (select users.* users left outer join companies on companies.id = users.company_id (((users.firstname '%s%' or users.lastname '%s%') or companies.name '%s%')) , (users.id = '11'))

and company_id user not empty.

when type puts @user.name, instead of giving me user name, gives me 'user'

many help.

although database 'users' table has column called 'company_id' user model has property called 'company'.

try unless @user.company_id.nil? @company = company.find(@user.company.id) end


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -