title: Refactor ruby on rails model
body: <p>Given the following code, </p>
  
  <p>How would you refactor this so that the method search_word has access to issueid?</p>
  
  <p>I would say that changing the function search_word so it accepts 3 arguments or making issueid an instance variable (@issueid) could be considered as an example of bad practices, but honestly I cannot find any other solution. If there's no solution aside from this, would you mind explaining the reason why there's no other solution? </p>
  
  <p>Please bear in mind that it is a Ruby on Rails model.</p>
  
  <pre><code>def search_type_of_relation_in_text(issueid, type_of_causality)
      relation_ocurrences = Array.new
      keywords_list = { 
          :C =&gt; ['cause', 'causes'],
          :I =&gt; ['prevent', 'inhibitors'],
          :P =&gt; ['type','supersets'],
          :E =&gt; ['effect', 'effects'],
          :R =&gt; ['reduce', 'inhibited'],
          :S =&gt; ['example', 'subsets'] 
      }[type_of_causality.to_sym]  
  
      for keyword in keywords_list
          relation_ocurrences + search_word(keyword, relation_type)
      end        
  
      return relation_ocurrences
  end
  
  
  def search_word(keyword, relation_type)
  relation_ocurrences = Array.new
  
  @buffer.search('//p[text()*= "'+keyword+'"]/a').each { |relation|
  
      relation_suggestion_url   = 'http://en.wikipedia.org'+relation.attributes['href']
      relation_suggestion_title = URI.unescape(relation.attributes['href'].gsub("_" , " ").gsub(/[\w\W]*\/wiki\//, ""))
  
      if not @current_suggested[relation_type].include?(relation_suggestion_url)
          if @accepted[relation_type].include?(relation_suggestion_url)
              relation_ocurrences &lt;&lt; {:title =&gt; relation_suggestion_title, :wiki_url =&gt; relation_suggestion_url, :causality =&gt; type_of_causality, :status =&gt; "A", :issue_id =&gt; issueid}
          else
              relation_ocurrences &lt;&lt; {:title =&gt; relation_suggestion_title, :wiki_url =&gt; relation_suggestion_url, :causality =&gt; type_of_causality, :status =&gt; "N", :issue_id =&gt; issueid}
          end
  
      end
  } 
  
  end
  </code></pre>