title: Merit gem - Display a specific badge and the users who obtained it
body: <p>I would like to create a method <code>badges#show</code> such as it is done here in <a href="https://stackoverflow.com/help/badges/222/altruist">StackOverFlow</a> in which the selected badge is displayed and the users who have obtained it. I have created a <code>BadgesController</code> in which I have the following:</p>
  
  <pre><code>  # Find badge
    before_action :set_badge, only: %i[show]
  
    # GET /badges/1
    def show; end
  
    private
  
    # Set badge
    def set_badge
      @badge = Merit::Badge.find(params[:badge_id])
    end
  </code></pre>
  
  <p>In <code>merit.rb</code> (I am only displaying the code for the first badge below):</p>
  
  <pre><code># Use this hook to configure merit parameters
  Merit.setup do |config|
    # Check rules on each request or in background
    # config.checks_on_each_request = true
  
    # Define ORM. Could be :active_record (default) and :mongoid
    # config.orm = :active_record
  
    # Add application observers to get notifications when reputation changes.
    # config.add_observer 'MyObserverClassName'
  
    # Define :user_model_name. This model will be used to grand badge if no
    # `:to` option is given. Default is 'User'.
    # config.user_model_name = 'User'
  
    # Define :current_user_method. Similar to previous option. It will be used
    # to retrieve :user_model_name object if no `:to` option is given. Default
    # is "current_#{user_model_name.downcase}".
    # config.current_user_method = 'current_user'
  end
  
  Merit::Badge.create!(
    id: 1,
    name: 'just-registered',
    description: 'New member',
    custom_fields: {
      icon_tag: 'user',
      category: 'user'
    }
  )
  
  # More badges [...]
  </code></pre>
  
  <p>However, when I try to display the badge name by doing <code>&lt;%= @badge.name %&gt;</code>, I get the following:
  <code>undefined method 'name' for #&lt;#&lt;Class:0x000000001290cc18&gt;:0x000000000c8c9d10&gt;</code>.</p>
  
  <p>The <strong>params</strong> I am passing at the point I am calling the <strong>badges#show</strong> method is <strong>1</strong> (in the url: <em>/badges/1</em>).</p>
  
  <p>The following lines throw the same error:</p>
  
  <ul>
  <li><code>@badge = Merit::Badge.find_by_id(params[:badge_id])</code></li>
  <li><code>@badge = Merit::Badge.find_by_id(params[:id])</code></li>
  <li><code>@badge = Merit::Badge.find(params[:id])</code></li>
  </ul>
  
  <p>If I change <code>@badge = Merit::Badge.find(params[:badge_id])</code> to <code>@badge = Merit::Badge.find(:id)</code> I get this: <code>Could not find Merit::Badge with key "id"</code>.</p>
  
  <p>When I try to debug my code, here is what happens with <code>&lt;%= debug @badge %&gt;</code> in the view (with <code>@badge = Merit::Badge.find(params[:badge_id])</code>):</p>
  
  <pre><code>#&lt;#&lt;Class:0x000000000da762c0&gt;:0x000000000af48a80 @keys=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], @mapper=#&lt;Ambry::Mapper:0x000000000af48f58 @klass=Merit::Badge(id, name, level, description, custom_fields), @adapter_name=:main, @indexes={}, @lock=#&lt;Thread::Mutex:0x000000000af48d28&gt;, @options={}, @hash={1=&gt;{:id=&gt;1, :name=&gt;"just-registered", :level=&gt;nil, :description=&gt;"New member", :custom_fields=&gt;{:icon_tag=&gt;"user", :category=&gt;"user"}} [...]
  
  </code></pre>
  
  <p>It displays a hash with all the badges I have in my initializer file <code>merit.rb</code>. I do not understand why the <strong>id</strong> parameter is not being passed by the controller.</p>
  
  <p><code>&lt;%= @badge.find(1).name %&gt;</code> in the view works fine however.</p>
  
  <p>What have I done wrong?</p>
  
  <p>Thank you in advance!</p>