Supporting Mobile Devices in Ruby on Rails - ruby-on-rails

What is the best way to develop a rails application that has special views for different mobile devices?
Basically I'm looking for something like this ASP.NET MVC solution: http://www.hanselman.com/blog/MixMobileWebSitesWithASPNETMVCAndTheMobileBrowserDefinitionFile.aspx

You might be looking for mobile_fu. It's a plugin that automatically changes the Rails format from :html to :mobile for Nokia, Blackberry, iPhone and Palm users. You can then just provide an {action}.mobile.erb to complement {action}.html.erb and it will render the mobile view. If you need something more fine-grained, it allows you to do:
is_mobile_device?
and there's various other helper methods

Two articles that use the iPhone as an example of serving up a different view based on a mobile sub-domain or a by detecting the user-agent. Essentially you'll create a different view using something like viewname.iphone.erb or viewname.mobile.erb and set the request.format variable to iphone or mobile respectively.
iPhone subdomains with Rails
iPhone on Rails - Creating an iPhone optimised version of your Rails site using iUI and Rails 2

I found this railscast extremely helpful for this situation: http://railscasts.com/episodes/199-mobile-devices
Hope it helps somebody out.

Ernie Miller wrote a post about how to provide mobile templates for your views. What's nice is that his approach doesn't force you to provide a mobile template if it isn't required. Instead, rails will fall back on your main template if the mobile version isn't found.

I recently wrote an article about this which you might find useful:
http://www.arctickiwi.com/blog/2-mobile-enable-your-ruby-on-rails-site-for-small-screens
Hope that helps
Jonno

I just saw a really illuminating video on this: http://www.engineyard.com/video/12678746 . There is a lot more to a decent mobile web experience then directly porting pages.

You might want to try Mobvious - https://github.com/jistr/mobvious
Detects mobiles vs. desktops + tablets, or if you want, detects mobile vs. tablets vs. desktops.
It also has support for manual selection by users (overriding the detection) if you want to allow users to manually switch interface versions.
And there is an extension mobvious-rails that adds some helpers to your controllers, views and CoffeeScript.

Related

Can I use CKEditor in my iOS application?

Well I've searched for the answer to this, and nothing seems to provide a clear solution... so here goes...
We have a web application that we are re-creating in iOS. Parts of the application utilize CKEditor to edit contents of templates (for sending emails, etc.).
Is there a way to use CKEditor within the iOS app, or is there something similar that anyone can recommend that provides the same base functionality?
Thanks, to all, in advance...
EDIT: (Thanks to the comment by #Dekel)
It should be noted that the editor needs to work whether the device is online or offline. So a true WebView item won't work (I believe - could be wrong).

Rails - Include different assets for mobile and desktop for an AngularJS app?

How can I include a different set of assets (CSS and JavaScript) for AngularJS views designed for phones and AngularJS views designed for desktop from a Rails API? The default template (application.html.erb or index.html) would typically only be loaded once, with the initial request, because it's an AngularJS application, so I do not think the usual desktop vs. mobile solutions for Rails apps will work.
Specifically, I am trying to combine a desktop app that uses AngularJS, Bootstrap, and jQuery with a mobile app that uses AngularJS and Ionic. The two apps will mostly have shared code, except for the views. The views will be very different, so a responsive approach will not be enough. I have not been able to find much guidance on this at all. Any help will be greatly appreciated.
Rails 4.1 offers variants so that you can have different view templates depending on the display type. Here's a more thorough example. It's really recent so there's not a lot out there about them yet.
If you're not on 4.1, you can look at using the Mobylette gem to achieve the same thing. You can then also have a completely different application.mobile.erb that includes different assets.
For flipping between which assets you're including, you can also take a look at this (the helper method part), but this won't address the issue with different sets of views across the board:
Mobile style switching in Rails 3, helper method vs media queries

Need to build mobile UI for a Rails app

I need to begin building a mobile UI for one of my Rails apps. A quick search brought me to the Titanium platform. Any thoughts on using this? Alternate suggestions are also welcome/appreciated.
In addition to my app rendering HTML, I am also able to easily create an API that will render JSON -- if that makes any difference regarding an answer.
Thanks in advance!
No experience with Titanium, but I would start with a Web UI, optimized for mobile (small) devices. This would avoid you to build several (well, two : one Android and one iOS) different clients applications.
Many current web framework now help with building mobile web application (look at Twitter Boostrap responsive features for an example).
You may want a native app afterward, especially if :
You want to interact with the phone/device (get contacts, push notifications, use sensors)
The native look and feel is very important to your application
Even so, a lot of very good apps are actually "hybrids", mixing native widgets with webview (take a look at 37 signals discussion about their new Basecamp iOS app).
In addition, if you are going the native way and are a Ruby developer (which I suppose), you may want to take a look at Ruboto (that allow to code applications for Android in Ruby) and RubyMotion (same for iOS).
I've decided to further pursue using Titanium and will most likely be creating a hybrid app. That said, both JQuery Mobile and Twitter Bootstrap also look nice! Thanks everyone for looking.

Preparing a RoR app for mobile application communication

I'm still implementing basic functionality in my app so I'm asking this now in case I need to re-think my design. My user interface in a "real browser" is a bunch of links which load data through AJAX. It also supports "normal non-AJAX" interaction. My controllers look somewhat like this:
if request.xhr?
render article
else
redirect_to article
This works very well so far and I have no problems. The problem is how I should add support for mobile apps. In the example above render article renders the file show.js.erb which looks like this:
$content.content("<%= escape_javascript(render "feeds/show") %>");
Obviously this won't do in a mobile application where I won't be working with a browser. I am thinkg of using phonegap to develop my app. I should note that I have zero experience with it.
So what I'm looking for is advice as how I should prepare support for a mobile application, any help is gladly appreciated. How should I be doing communication and are there anything special I should consider from hereon when I continue developing the backend?
There is an article about this. It's been written a few years back and uses IUI and Rails 2. The conventions in this article still prove quite valid in later versions of Rails.
However, the concepts of what is needed to get you started is explained therein. It speaks of using an app called iPhoney, which helps in the debugging stages.
Second, the article explains how one would be able to configure Rails iPhone mime type and how to detect iPhone user agents, among other setups as well.
If you haven't already. I would suggest looking at jQuery Mobile. Which may suit your requirements as well.
A more up-to-date article can be found here.

RoR technology: is there any mobile framework on Rails?

Can we make a mobile application with the help of RoR technology?
Ruby on Rails is a webframework designed to, well.. create websites. If you change the website template of RoR to fit the small screens of handhelds/mobile phones/smartphones you can of course use it to serve websites to those devices.
Best wishes,
Fabian
Actually there is, "open source framework Rhodes contains the first implementation of Ruby for every major smartphone operating system: iPhone, Android, BlackBerry, Windows Mobile and Symbian." Also see this.

Resources