<commit_before>module BBS
  class Post < ActiveRecord::Base
    belongs_to :user
    belongs_to :category

    validates :title, :body, :user_id, :category_id, presence: true

    default_scope { order('created_at DESC') }

    def is_owner?(user)
      self.user.name == user.name
    end

    # Named Scopes
    class << self
      def by_category(category_name)
        joins(:category).where(categories: { name: category_name })
      end

      def by_owner(user_name)
        joins(:user).where(users: { name: user_name })
      end
    end
  end
end<commit_msg>Change scopes, now it works fine<commit_after>module BBS
  class Post < ActiveRecord::Base
    belongs_to :user
    belongs_to :category

    validates :title, :body, :user_id, :category_id, presence: true

    default_scope { order('created_at DESC') }

    def is_owner?(user)
      self.user.name == user.name
    end

    # Named Scopes
    class << self
      def by_category(category_name)
        Category.where(categories: { name: category_name }).joins(:posts)
      end

      def by_owner(user_name)
        User.where(users: { name: user_name }).joins(:posts)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10197086546700942, 'fraction_numerical': 0.0, 'mean_word_length': 2.8421052631578947, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '184921', 'n_tokens_mistral': 380, 'n_tokens_neox': 375, 'n_words': 92}