activerecord - Rails relational issue - Find user's next outing -


I have an outgoing table, which basically has some information about an 'outgoing'.

In the form of just a note, there are many employees outside, therefore the outward_ID of the employees table

Now, I need the user's Next Find out, like in the first outing where outing.start_time & gt; time. Now I have found in my user.rb model:

  is_im: crew_users_maya: crews ,: through = & gt; : Crew_users have_many: outings ,: through = & gt; : Crews  

And when I try to do this:

  & gt; & Gt; Users.find (1) .outings  

I get this error:

  ActiveRecord :: Statement invalid: Mysql :: error: unknown column 'crews. Where in 'user_id': 'selection' outing. * Out of 'Outgoing' INNER, `` Outgoing `` `` `` `` crews```_outing_id. ((`Crews`.user_id = 1))  

Any ideas? Like I said, my goal is to get the user's next out of the present time, so it can be very good to know about it!

If you are doing a double : through , then you try this And can reverse, by filtering outing records instead. For this, the SQL will look something like this:

  is excluded from SELECT outings.id. Crews.id = outings.crew_id crews_users.crew_id = crews_users on crews.id where crews_users user_id =? And start_time & gt; = NOW () ORDER BY created_at LIMIT 1  

There is a quick and dirty view to run this and to remove the outing_id value, then Outing.find with.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -