Ruby on Rails Sunday, May 8, 2016

On 8 May 2016 at 03:01, Ryan Bell <lists@ruby-forum.com> wrote:
> Unless you've done something to explicitly change it, the table name for
> a model will be plural. So instead of `rsvp.user_id`, you may need
> `rsvps.user_id`.

In fact you don't need rsvp at all here
.select('user_id', 'event_sessions.name')

As always in this sort of situation with a complex statement that is
not working as intended, a useful technique is to build the statement
up a bit at a time, so start with
previous_rsvps = Rsvp.select('user_id', 'event_sessions.name')
and make sure previous_rsvps.count does not fail, then try
previous_rsvps = Rsvp.select('user_id',
'event_sessions.name').where(user_id: selected_attendees)
and so on till it fails. That may well give you a clue.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvhZdxKLvuTe7Ojt4PDrkRZCX4tZTYPBvU%2BtgBtiB4gYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment