title: Rails find_by and model foreign key
body: <p>I'm studying Ruby on Rails those days to improve myself as a developer so I've started to rewrite a php website of mine to play with the framework.<br>
  Basically the site is a source code aggregator, hence i have a Language model and a Source model:</p>
  
  <pre><code>class Language &lt; ActiveRecord::Base
    has_many :sources
  end
  
  class Source &lt; ActiveRecord::Base
    belongs_to :language
  end
  </code></pre>
  
  <p>Bound with the language_id foreign key in the source table.<br>
  One of the main routes of the website is:</p>
  
  <pre><code>get ':language_name/:source_name.html' =&gt; 'source#show'
  </code></pre>
  
  <p>So for example:</p>
  
  <pre><code>/ruby/discover-if-a-number-is-prime.html
  </code></pre>
  
  <p>In the SourceController I have declared the following:</p>
  
  <pre><code>class SourceController &lt; ApplicationController
    def show
      language_name, source_name = params[:language_name], params[:source_name]
      @language = Language.find_by_name(language_name) || not_found
      @source = Source.find_by( name: source_name, language_id: @language.id ) || not_found
    end
  end
  </code></pre>
  
  <p>Is there a clever way to perform those two queries ?<br>
  Maybe something like</p>
  
  <pre><code>@source = Source.find_by_name_and_language_name( source_name, language_name ) || not_found
  </code></pre>
  
  <p>I'm sorry if this is a stupid question, I'm reading Agile Web Development with Rails 3.2 too but in the meantime I'd like to experiment a little.<br>
  Thanks</p>