In my show action I’d like to pass along all data that has a user_id == current_user.id (since I’m using the Devise gem) AND params[:id]
I created this
@customer = Customer.where(:id => params[:id], :user_id => current_user.id)
But when I try to pull a field, for example @customer.company I get the error undefined methodcompany’`. I know there is data for that field too.
What’s wrong?
ActiveRecord::Base#wherereturns an array of matching results. To fetch the first result, you need to run@customer = Customer.where(...).first