On Sunday, July 21, 2019 at 3:41:54 PM UTC-7, Matthew Gibbons wrote:
>
> Okay, so I have this:
>
>     class Team < Sequel::Model
>       many_to_many :users
>
>       many_to_many(:admins, class: User, :join_table => :teams_users, 
> :right_key => :user_id) do |ds|
>         ds.where(Sequel[:teams_users][:role] => 'admin')
>       end
>     end
>
> Which give me :users and ;admins. #add_user works, however #add_admin does 
> the same as #add_user - the where clause in the dataset is not respected.
>

add_admin would insert a record into the join table.  INSERT doesn't use a 
WHERE clause, so that is expected.  If you want to set the :role entry in 
add_admin, you want to use the :adder association option.

Thanks,
Jeremy 

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/4261c169-00c0-4331-91ce-122aae59eec6%40googlegroups.com.

Reply via email to