Reputation: 1262
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
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