title: Passing parameters to ruby methods in Rails
body: <p>I have method inside AplicationController which I want to be reusable from all controllers:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>class AplicationController &lt; ActionController::Base
                                                     
  protected
                                                     
  def set_cartridge_values(cartridge, cartridge_value, param_value)
      @quantity = cartridge.cartridge_value.to_i + param_value.to_i
      cartridge.update(cartridge_value: @quantity)
  end</code></pre>
  </div>
  </div>
  </p>
  
  <p>I in some controller I want to cal this method like that:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>set_cartridge_values(@cartridge, ? ,params[:toner_kg][:weight])</code></pre>
  </div>
  </div>
  </p>
  
  <p>In place of  ? mark I dont know how to pass that parameter.</p>
  
  <p>@cartridge - is a varaible defined before</p>
  
  <p>params[:toner_kg][:weight] - is a value</p>
  
  <p>and cartridge_value - is a attribute of a cartridge.</p>
  
  <p>For example I want to pass toner_gr attribute of a cartridge model and update that attribute.</p>