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! While you're at it, check out some resources Treehouse students have shared here.
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 trialMichael Trilford
7,232 PointsIs there a course to learn about Variants for Rails?
"Variants allows you to have different templates and action responses for the same mime type (say, HTML). This is a magic bullet for any Rails app that's serving mobile clients. You can now have individual templates for the desktop, tablet, and phone views while sharing all the same controller logic. This is the secret sauce behind Basecamp's hybrid native/HTML strategy for mobile apps: One Rails app serving desktop browsers, mobile browsers, native mobile apps. The reuse benefits are immense and the productivity boost staggering. Really." - From the interwebs.
2 Answers
David Moore
13,916 PointsI've not seen it covered here and don't really expect it since it seems like a very specific use case. A quick search, however, returned this walkthrough:
http://tech.pro/tutorial/2049/how-to-use-rails-41-actionpack-variants
Seems pretty straight forward so long as you understand rendering in rails.
Michael Trilford
7,232 PointsYeh, we were finally getting around to having a play yesterday at work.
You essentially setup the new layout with the right format on the end ( index.html+phone.erb ), and install the "browser" gem. ( I think )
Boom, it works, pretty nice.
Thanks, rails is pretty neat.
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 PointsMichael Trilford was the answer below helpful? If so, please indicate that by selecting it as Best Answer. If not, please elaborate more so that we could assist you further.