您好我希望将此sql转换为rails active record
select a.*
from public.users a
inner join public.user_by_groups gp2 on gp2.user_id = a.id and gp2.active = 'true'
and gp2.group_id in
(SELECT gp.group_id
FROM public.users u
inner join public.user_by_groups gp on gp.user_id = u.id and gp.active = 'true'
where u.id = '4')
我的模型(与多对多关系)
class User < ActiveRecord::Base
has_many :user_by_groups
has_many :groups, through: :user_by_groups
end
class UserByGroup < ApplicationRecord
# Relations
belongs_to :user
belongs_to :group
end
class Group < ApplicationRecord
has_many :user_by_groups
has_many :users, through: :user_by_groups
end
单身就有了第一个问题:
@class_mates = User.joins(:user_by_groups)
.where(user_by_groups: { user_id: 4 })
.where(user_by_groups: { active: true })
答案 0 :(得分:1)
试试这个:
textView.setText(R.string.html); // this will properly format the text
textView.setText(getText(R.string.html)); // this will properly format the text
textView.setText(getString(R.string.html)); // this will ignore the formatting tags