Dan
Dan

Reputation: 1262

Using mobile-fu with rails

I am just starting out with RoR, and I'm having some problems. I'm using the Mobile-Fu plugin to load my application.mobile.haml file. The index page loads fine, but whenever I select another page, it loads the non-mobile haml file.

class EventsController < ApplicationController
  respond_to :html, :mobile

  before_filter :get_event, :except => [:index]
  before_filter :is_mobile

  def index
    @events = Event.all
    respond_with(@events)
  end

  def show
    respond_with(@event)
  end

  private
  def is_mobile
    @mobile = is_mobile_device?
  end

  def get_event
    @event = params[:id].present? ? Event.find(params[:id]) : Event.new
  end
end

Upvotes: 2

Views: 1564

Answers (1)

Dan
Dan

Reputation: 1262

I fixed it by changing one my private functions to this:

 private
 def is_mobile
    request.format = :mobile if is_mobile_device?
 end

Upvotes: 4

Related Questions