title: Embedding Youtube Video in Rails App
body: <p>I am trying to add a you tube clip to my rails app.</p>
  
  <p>I have a profiles helper that says</p>
  
  <pre><code>  def embed(youtube_url)
       youtube_id = youtube_url.split("=").last
       content_tag(:iframe, nil, src: "//www.youtube.com/embed/#{youtube_id}")
     end
  </code></pre>
  
  <p>In my view i have</p>
  
  <pre><code>  &lt;div class="embed-container"&gt; 
          &lt;%= embed(@profile.youtube_url) %&gt;  
        &lt;/div&gt;
  </code></pre>
  
  <p>I get an error with my helper that says:</p>
  
  <pre><code>NoMethodError at /profiles/8
  undefined method `split' for nil:NilClass
  </code></pre>