Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Malachai Frazier
7,352 PointsRails 3.2.9 Audio Tag...
If I have one of these
<%=audio_tag track.audio,:type =>"mp3/audio",:controls =>true,:autoplay =>false,:preload =>:auto%>
Where do I put this?
<p>Your browser does not support the audio element. Use Chrome. </p>
4 Answers

Malachai Frazier
7,352 PointsThis browser gem is the way... Put this in your controller:
require "browser"
and then this: @browser = Browser.new(:ua => request.user_agent)
Now use this in your view:
<% if @browser.firefox? %> <p class="disclaimer">Your browser does not support the audio element, sorry about this. Use Chrome, please.</p> <% else %> <div> <%= audio_tag track.audio, :type => "mp3/audio", :controls => true, :autoplay => false %> </div> <% end %>

Andrew Chalkley
Treehouse Guest TeacherYou should require the browser gem in your Gemfile in the root of your Rails app and then call bundle install. Then your gems are required in one place. No need to include a require in a controller.
Hope all is well with your new addition!

Malachai Frazier
7,352 PointsHmm. I put all my gems in the Gemfile, always. But without the require in my controllers, I'd get this error;
no such file to load --browser
Perhaps I need to just restart my server or something simple... I'll try to remove that require during refactor time and see what happens!

Andrew Chalkley
Treehouse Guest TeacherRestarting your server may be "required" :)