0
基本上我想使用範圍使用關聯來獲取數據。範圍從數據庫Rails中獲取關聯的數據3
用戶和帖子之間的關聯。
belongs_to :user # on posts model
has_many :posts, :dependent => :destroy #on user model
查詢
數據庫具有不同用戶創建的職位數的記錄,所以我想獲取所有那些帖子,其post.user.name沒有一個模式(整數等)在裏面。
我想在其上使用
Post.scope_name
u能舉一個例子爲「post.user.name沒有一個模式(整數等) 「 –
艾米特,不知何故,我已經使用我在答案中提到的範圍計算出了預期的結果。 – RailsEnthusiast