Git Product home page Git Product logo

mobylette's Introduction

Mobylette 2.0+ deprecated the respond_to_mobile_requests method.
Now you must use `include Mobylette::RespondToMobileRequests` instead.
to configure it, see the configuration.
Also stylesheet and javascript helpers were removed.

Mobylette 1.6+ only supports Ruby 1.9.2+
For Ruby 1.8.7 support, please use version < 1.6

Mobylette

<img src=“https://secure.travis-ci.org/tscolari/mobylette.png” /> <img src=“https://gemnasium.com/tscolari/mobylette.png” /> <img src=“https://codeclimate.com/github/tscolari/mobylette.png” />

This gem works by adding the ‘mobile’ format to your rails application. Whenever a request come from a mobile device, if you have your controller mobile enabled, it shall render the view.mobile.erb instead of the view.html.erb (or haml, or whatever).

How does it work?

By adding “respond_to_mobile_requests” in your application_controller (or any other controller), your controllers (or that controller) will understand mobile requests as a new mime type alias “mobile”. This will make the controller to search for the .mobile.erb file instead of the .html.erb. Also you will be able to do:

respond_to do |format|
  format.html   { ... }
  format.mobile { ... }
end

Installation

Add the gem to your gemfile:

gem 'mobylette'

And add to your ApplicationController.rb (for enabling it to all your controllers) or to the controllers you want this functionality on:

include Mobylette::RespondToMobileRequests

After that, you may start adding your .mobile. views.

Helpers

  • is_mobile_request?

    This helper returns true if the request comes from a mobile device, false if it does not.

  • is_mobile_view?

    Returns if the current format is :mobile or not.

  • request_device?

    Returns true/false if the current request comes from the device passed as parameter.

    Examples:

    request_device?(:iphone)
    
    request_device?(:android)
    

    Only :iphone, :ipad, :ios and :android are recognized by default. But you can add other devices, check configuration.

Configuration

You can set the configuration with the mobylette_config method:

mobylette_config do |config|
  ... configuration
end

Custom User Agents

Mobylette works upon detecting the user agent of the visitor browser. By default it will detect any mobile user agent. But you can customize this by passing a proc with a regex of any matching user agent you may wish.

mobylette_config do |config|
  config[:mobile_user_agents] = proc { %r{iphone|ipad}i }
end

Skipping User Agents

If you need to exclude one or more user agents from the mobile format, lets say ipad for example, you may use the :skip_user_agents option:

mobylette_config do |config|
  config[:skip_user_agents] = [:ipad]
end

Fall Backs

Fall backs are handled as a chain of formats. By default the only chain is ‘:mobile => [:mobile, :html]`. You can override this and add your own fall back chains using the `mobylette_config`.

mobylette_config do |config|
  config[:fallback_chains] = {
    mobile: [:mobile, :html],
    iphone: [:iphone, :mobile, :html],
    ...
  }
end

When you create a custom format with fall back chains, ‘:iphone` for example, you must register it as a Mime::Type:

# config/initializers/mime_types.rb
Mime::Type.register_alias 'text/html', :iphone
# this is very important, don't forget!
# :mobile is already registered!

If you don’t want any fall backs, just set it to:

mobylette_config do |config|
  config[:fallback_chains] = { mobile: [:mobile] }
end

XHR Requests

By default the mobile device verification will skip XHR requests, and these will be served as if mobylette wasn’t there. You can override this behavior by setting the :skip_xhr_requests option to false on your controller:

mobylette_config do |config|
  config[:skip_xhr_requests] = false
end

You may need to use this if you are using JQuery mobile or something similar in your application.

Registering Mobile Devices

Mobylette 3.0+ has a ‘request_device?` helper. By default only :iphone, :ipad, :ios and :android devices come registered. But you can register any device using the `mobylette_config` method:

mobylette_config do |config|
  config[:devices] = { my_unique_phone: %r{UniquePhone 1.2.3}, ... }
end

Note: This will not add the device to the mobile user_agent detection. For that read #Custom User Agents.

Skipping mobile filter

In the case you need to skip a mobile_request for been treated as mobile, you can pass the ‘skip_mobile=true` param to the url/request.

For example, you are using jquery_mobile and by that ‘:skip_xhr_requests = false`, but there is a special case where you need to process an Ajax, then you can use this param.

Forcing/Ignoring Mobile Requests

You may force your user to aways render the mobile format, or to aways render the default request format (when the request comes from a mobile device). You can use the session var :mobylette_override for doing it:

session[:mobylette_override] = :ignore_mobile

This will skip the code that would force the mobile format. By doing this, your user will aways render the ‘original’ version of your app.

session[:mobylette_override] = :force_mobile

This will force the mobile format rendering, no matter from where the user is requesting it (unless it’s a xhr request).

session[:mobylette_override] = nil

Notice:

Be sure you are forcing / skiping mobile requests e.g. in a before_filter like : skip_or_force_mobile BEFORE you are including the Mobylette::RespondToMobileRequests module. Mobylette adds own before_filter to check the session var which would be executed before your filter.

class ApplicationController < ActionController::Base 
  #...

  before_filter :skip_or_force_mobile

  include Mobylette::RespondToMobileRequests

  mobylette_config do |config|
    config[:mobile_user_agents] = proc { %r{iphone|android}i }
    config[:skip_user_agents]   = []
  end

  # ...
  private 

  def skip_or_force_mobile
    session[:mobylette_override] = :ignore_mobile if params[:skip_mobile]
    session[:mobylette_override] = :force_mobile if params[:force_mobile]
  end
end

This will disable any override (default).

If you need to customize how mobile requests are identified you can override the ‘is_mobile_request?` method in your controller, with your own logic. For example, if you want the mobile.app.com to render mobile views, and the app.com to render the normal views:

class ApplicationController << ActionController::Base
  include Mobylette::RespondToMobileRequests

  ...

  private

  def is_mobile_request?
    request.host == "mobile.app.com"
  end
end

Testing

Don’t drive your mobylette without your Helmet! It’s safer to do tests!

For testing, include the Mobylette::Helmet module to your test/test_helpers.rb:

require 'mobylette/helmet'
include Mobylette::Helmet

For RSpec: add to your spec/spec_helpers.rb or create a spec/support/mobylette.rb with the following:

require 'mobylette/helmet'
RSpec.configure do |config|
  config.include Mobylette::Helmet, :type => :controller
end

This will add 3 methods to your test scope:

force_mobile_request_agent(agent = 'Android')

This will force a mobile user_agent, allowing you to test mobile requests.

reset_test_request_agent

This will reset your user_agent to the test default “Rails Testing”. You don’t need to call this every time, all your requests by default are “Rails Testing” in your test env.

set_session_override(override_value)

This will force the session_override value in the users session. Values possible values are: :ignore_mobile and :force_mobile

Friendly note: on your tests, call these functions BEFORE you make the request, otherwise they are useless =p

License

MIT License. Copyright 2012 Tiago Scolari.

mobylette's People

Contributors

bnmrrs avatar douglasdollars avatar hstove avatar minamijoyo avatar sanemat avatar towynlin avatar tscolari avatar wesgibbs avatar zbelzer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mobylette's Issues

MissingTemplate error rendering partial

I saw in other comments on issue #5 that you were working on fallback for partials. Is this implemented and I'm doing something wrong, or is there just not an issue for tracking this?

JQuery Autocomplete field only works once

I'm trying to figure out what I might be doing wrong here. I'm not sure how mobylette works but it seems that is rebuilds only partial pieces of the web page instead of a full reload when is causing my autocomplete code to stop working after its first use. I've looked on Stack Overflow for a solution to this problem and haven't found anything substantial.

I isolated a piece of my project into a rails application that you can download here:
https://github.com/aarona/mobylette_test

There is a sql file you will need to use to insert about 500 test records for a parts database. You can find that file under the /doc folder.

Go to localhost:3000 after running the server and click link to get to the parts page. You will see that after you've submitted your first part entry, the auto complete function stops working. You have to refresh the page to get it to work again.

ArgumentError - wrong number of arguments (5 for 4):

Hi,

Using Ruby 2.1.5, Rails 4.2.5.1 and Mobylette 3.5, I am getting the following error. However, when I override is_mobile_request method in ApplicationController, it works fine. I looked at the Mobylette code, and the method doesn't take 4 arguments.... It looks like it's with regard to find_templates method in Resolver class, but that's as far as I was able to guess....

Any help would be appreciated!

ArgumentError - wrong number of arguments (5 for 4):
  actionview (4.2.5.1) lib/action_view/template/resolver.rb:116:in `block in find_all'
  actionview (4.2.5.1) lib/action_view/template/resolver.rb:152:in `block in cached'
  actionview (4.2.5.1) lib/action_view/template/resolver.rb:63:in `cache'
  actionview (4.2.5.1) lib/action_view/template/resolver.rb:151:in `cached'
  actionview (4.2.5.1) lib/action_view/template/resolver.rb:115:in `find_all'
  actionview (4.2.5.1) lib/action_view/path_set.rb:70:in `block (2 levels) in _find_all'
  actionview (4.2.5.1) lib/action_view/path_set.rb:66:in `block in _find_all'
  actionview (4.2.5.1) lib/action_view/path_set.rb:65:in `_find_all'
  actionview (4.2.5.1) lib/action_view/path_set.rb:54:in `find_all'
  actionview (4.2.5.1) lib/action_view/path_set.rb:46:in `find'
  actionview (4.2.5.1) lib/action_view/lookup_context.rb:121:in `find'
  actionview (4.2.5.1) lib/action_view/renderer/abstract_renderer.rb:18:in `find_template'
  actionview (4.2.5.1) lib/action_view/renderer/template_renderer.rb:40:in `determine_template'
  actionview (4.2.5.1) lib/action_view/renderer/template_renderer.rb:8:in `render'
  actionview (4.2.5.1) lib/action_view/renderer/renderer.rb:42:in `render_template'
  actionview (4.2.5.1) lib/action_view/renderer/renderer.rb:23:in `render'
  actionview (4.2.5.1) lib/action_view/rendering.rb:100:in `_render_template'
  actionpack (4.2.5.1) lib/action_controller/metal/streaming.rb:217:in `_render_template'
  actionview (4.2.5.1) lib/action_view/rendering.rb:83:in `render_to_body'
  actionpack (4.2.5.1) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
  actionpack (4.2.5.1) lib/action_controller/metal/renderers.rb:37:in `render_to_body'
  actionpack (4.2.5.1) lib/abstract_controller/rendering.rb:25:in `render'
  actionpack (4.2.5.1) lib/action_controller/metal/rendering.rb:16:in `render'
  actionpack (4.2.5.1) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
  activesupport (4.2.5.1) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
  /Users/yangtheman/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
  activesupport (4.2.5.1) lib/active_support/core_ext/benchmark.rb:12:in `ms'
  actionpack (4.2.5.1) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
  actionpack (4.2.5.1) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
  actionpack (4.2.5.1) lib/action_controller/metal/instrumentation.rb:43:in `render'
  app/controllers/titan_controller.rb:15:in `homepage'
  actionpack (4.2.5.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (4.2.5.1) lib/abstract_controller/base.rb:198:in `process_action'
  actionpack (4.2.5.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (4.2.5.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
  activesupport (4.2.5.1) lib/active_support/callbacks.rb:117:in `call'
  activesupport (4.2.5.1) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
  activesupport (4.2.5.1) lib/active_support/callbacks.rb:505:in `call'
  activesupport (4.2.5.1) lib/active_support/callbacks.rb:92:in `__run_callbacks__'
  activesupport (4.2.5.1) lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
  activesupport (4.2.5.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (4.2.5.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (4.2.5.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (4.2.5.1) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
  activesupport (4.2.5.1) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (4.2.5.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.2.5.1) lib/active_support/notifications.rb:164:in `instrument'
  actionpack (4.2.5.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (4.2.5.1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  actionpack (4.2.5.1) lib/abstract_controller/base.rb:137:in `process'
  actionview (4.2.5.1) lib/action_view/rendering.rb:30:in `process'
  actionpack (4.2.5.1) lib/action_controller/metal.rb:196:in `dispatch'
  actionpack (4.2.5.1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  actionpack (4.2.5.1) lib/action_controller/metal.rb:237:in `block in action'
  actionpack (4.2.5.1) lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
  actionpack (4.2.5.1) lib/action_dispatch/routing/route_set.rb:43:in `serve'
  actionpack (4.2.5.1) lib/action_dispatch/journey/router.rb:43:in `block in serve'
  actionpack (4.2.5.1) lib/action_dispatch/journey/router.rb:30:in `serve'
  actionpack (4.2.5.1) lib/action_dispatch/routing/route_set.rb:815:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  http_accept_language (2.0.5) lib/http_accept_language/middleware.rb:14:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/rack/agent_hooks.rb:30:in `traced_call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/rack/browser_monitoring.rb:23:in `traced_call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  rack (1.6.4) lib/rack/deflater.rb:35:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  rack (1.6.4) lib/rack/etag.rb:24:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  rack (1.6.4) lib/rack/head.rb:13:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  actionpack (4.2.5.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  actionpack (4.2.5.1) lib/action_dispatch/middleware/flash.rb:260:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
  rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  actionpack (4.2.5.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  fastly-rails (0.4.0) lib/fastly-rails/rack/remove_set_cookie_header.rb:9:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  actionpack (4.2.5.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.2.5.1) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
  activesupport (4.2.5.1) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
  activesupport (4.2.5.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (4.2.5.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  actionpack (4.2.5.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  actionpack (4.2.5.1) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  rollbar (2.7.1) lib/rollbar/middleware/rails/rollbar.rb:24:in `block in call'
  rollbar (2.7.1) lib/rollbar.rb:854:in `scoped'
  rollbar (2.7.1) lib/rollbar/middleware/rails/rollbar.rb:22:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  actionpack (4.2.5.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  rollbar (2.7.1) lib/rollbar/middleware/rails/show_exceptions.rb:22:in `call_with_rollbar'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  actionpack (4.2.5.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  railties (4.2.5.1) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.5.1) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.5.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.5.1) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.5.1) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.5.1) lib/rails/rack/logger.rb:20:in `call'
  quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  actionpack (4.2.5.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  rack (1.6.4) lib/rack/runtime.rb:18:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  activesupport (4.2.5.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  actionpack (4.2.5.1) lib/action_dispatch/middleware/static.rb:116:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
   () Users/yangtheman/.rvm/gems/ruby-2.1.5@pebble-frontend/bundler/gems/font_assets-ec089aeecde3/lib/font_assets/middleware.rb:30:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  railties (4.2.5.1) lib/rails/engine.rb:518:in `call'
  railties (4.2.5.1) lib/rails/application.rb:165:in `call'
  newrelic_rpm (3.11.0.283) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
  /Users/yangtheman/Library/Application Support/Pow/Versions/0.5.0/node_modules/nack/lib/nack/server.rb:155:in `handle'
  /Users/yangtheman/Library/Application Support/Pow/Versions/0.5.0/node_modules/nack/lib/nack/server.rb:109:in `rescue in block (2 levels) in start'
  /Users/yangtheman/Library/Application Support/Pow/Versions/0.5.0/node_modules/nack/lib/nack/server.rb:106:in `block (2 levels) in start'
  /Users/yangtheman/Library/Application Support/Pow/Versions/0.5.0/node_modules/nack/lib/nack/server.rb:96:in `block in start'
  /Users/yangtheman/Library/Application Support/Pow/Versions/0.5.0/node_modules/nack/lib/nack/server.rb:76:in `start'
  /Users/yangtheman/Library/Application Support/Pow/Versions/0.5.0/node_modules/nack/lib/nack/server.rb:12:in `run'
  /Users/yangtheman/Library/Application Support/Pow/Versions/0.5.0/node_modules/nack/bin/nack_worker:4:in `<main>'

Mobylette not falling back to HTML views for me

I am using Mobylette 1.6, Rails 3.1, and Ruby 1.9.3.

if i set in my app controller.

respond_to_mobile_requests :fall_back => :html

It does not load my HTML views I get a missing template error.

Missing template home/index, application/index with {:handlers=>[:erb, :builder, :coffee], :formats=>[:mobile], :locale=>[:en, :en]}.

I have an home/index.html.erb.

If I create home/index.mobile.erb it works.

Am I doing something wrong? It was my understanding that Mobylette will fall back to .html.erb if .mobile.erb does not exist.

Readme typo

Should be include Mobylette::RespondToMobileRequests, not include Mobyllete::RespondToMobileRequests

NoMethodError (undefined method `[]' for nil:NilClass):

I'm using Rails 3.2.13 and Ruby 1.9.3, and I'm having the following error when running "request_device?(:android)":

 NoMethodError (undefined method `[]' for nil:NilClass):
  vendor/gems/ruby/1.9.1/gems/mobylette-3.4.0/lib/mobylette/respond_to_mobile_requests.rb:169:in `user_agent_excluded?'
  vendor/gems/ruby/1.9.1/gems/mobylette-3.4.0/lib/mobylette/respond_to_mobile_requests.rb:141:in `is_mobile_request?'
  vendor/gems/ruby/1.9.1/gems/mobylette-3.4.0/lib/mobylette/respond_to_mobile_requests.rb:163:in `respond_as_mobile?'
  vendor/gems/ruby/1.9.1/gems/mobylette-3.4.0/lib/mobylette/respond_to_mobile_requests.rb:207:in `handle_mobile'
  vendor/gems/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:418:in `_run__855330179__process_action__151888460__callbacks'
  vendor/gems/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
  vendor/gems/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  vendor/gems/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/callbacks.rb:17:in `process_action'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/rescue.rb:29:in `process_action'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
  vendor/gems/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `block in instrument'
  vendor/gems/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  vendor/gems/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `instrument'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
  vendor/gems/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/base.rb:121:in `process'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/rendering.rb:45:in `process'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal.rb:203:in `dispatch'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal.rb:246:in `block in action'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in `call'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:36:in `call'
  vendor/gems/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
  vendor/gems/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
  vendor/gems/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:612:in `call'
  vendor/gems/ruby/1.9.1/gems/warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
  vendor/gems/ruby/1.9.1/gems/warden-1.2.1/lib/warden/manager.rb:34:in `catch'
  vendor/gems/ruby/1.9.1/gems/warden-1.2.1/lib/warden/manager.rb:34:in `call'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  vendor/gems/ruby/1.9.1/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call'
  vendor/gems/ruby/1.9.1/gems/rack-1.4.5/lib/rack/conditionalget.rb:25:in `call'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/head.rb:14:in `call'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/flash.rb:242:in `call'
  vendor/gems/ruby/1.9.1/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
  vendor/gems/ruby/1.9.1/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/cookies.rb:341:in `call'
  vendor/gems/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/query_cache.rb:64:in `call'
  vendor/gems/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  vendor/gems/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `_run__498945309__call__30700166__callbacks'
  vendor/gems/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
  vendor/gems/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  vendor/gems/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/reloader.rb:65:in `call'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  vendor/gems/ruby/1.9.1/gems/railties-3.2.13/lib/rails/rack/logger.rb:32:in `call_app'
  vendor/gems/ruby/1.9.1/gems/railties-3.2.13/lib/rails/rack/logger.rb:16:in `block in call'
  vendor/gems/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/tagged_logging.rb:22:in `tagged'
  vendor/gems/ruby/1.9.1/gems/railties-3.2.13/lib/rails/rack/logger.rb:16:in `call'
  vendor/gems/ruby/1.9.1/gems/quiet_assets-1.0.2/lib/quiet_assets.rb:18:in `call_with_quiet_assets'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/request_id.rb:22:in `call'
  vendor/gems/ruby/1.9.1/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
  vendor/gems/ruby/1.9.1/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
  vendor/gems/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  vendor/gems/ruby/1.9.1/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
  vendor/gems/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/static.rb:63:in `call'
  vendor/gems/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:479:in `call'
  vendor/gems/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:223:in `call'
  vendor/gems/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/abstract_request_handler.rb:516:in `accept_and_process_next_request'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb:206:in `start_request_handler'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb:171:in `block in handle_spawn_application'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/utils.rb:470:in `safe_fork'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb:166:in `handle_spawn_application'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server.rb:180:in `start'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb:129:in `start'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
  <internal:prelude>:10:in `synchronize'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.17/helper-scripts/passenger-spawn-server:99:in `<main>'

Ignore mobile on JSON requests

I have an iPhone app that is requesting JSON from my server. Rather than defaulting to the JSON respond_to, it is responding as if mobile.

uninitialized constant ActionView::FileSystemResolver (NameError)

Hi,

I am facing following error when I run rails s command(I am using rails 4.1.5 and ruby 2.1.2)

/home/cis/.rvm/gems/ruby-2.1.2@demo_cache/bundler/gems/mobylette-08781e203eaa/lib/mobylette/resolvers/chained_fallback_resolver.rb:3:in <module:Resolvers>': uninitialized constant ActionView::FileSystemResolver (NameError) from /home/cis/.rvm/gems/ruby-2.1.2@demo_cache/bundler/gems/mobylette-08781e203eaa/lib/mobylette/resolvers/chained_fallback_resolver.rb:2:inmodule:Mobylette'
from /home/cis/.rvm/gems/ruby-2.1.2@demo_cache/bundler/gems/mobylette-08781e203eaa/lib/mobylette/resolvers/chained_fallback_resolver.rb:1:in <top (required)>' from /home/cis/.rvm/gems/ruby-2.1.2@demo_cache/bundler/gems/mobylette-08781e203eaa/lib/mobylette.rb:5:inmodule:Mobylette'
from /home/cis/.rvm/gems/ruby-2.1.2@demo_cache/bundler/gems/mobylette-08781e203eaa/lib/mobylette.rb:3:in <top (required)>' from /home/cis/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.2/lib/bundler/runtime.rb:76:inrequire'
from /home/cis/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.2/lib/bundler/runtime.rb:76:in block (2 levels) in require' from /home/cis/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.2/lib/bundler/runtime.rb:72:ineach'
from /home/cis/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.2/lib/bundler/runtime.rb:72:in block in require' from /home/cis/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.2/lib/bundler/runtime.rb:61:ineach'
from /home/cis/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.2/lib/bundler/runtime.rb:61:in require' from /home/cis/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.7.2/lib/bundler.rb:133:inrequire'
from /home/cis/demo_cache/config/application.rb:7:in <top (required)>' from /home/cis/.rvm/gems/ruby-2.1.2@demo_cache/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:79:inrequire'
from /home/cis/.rvm/gems/ruby-2.1.2@demo_cache/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:79:in block in server' from /home/cis/.rvm/gems/ruby-2.1.2@demo_cache/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:76:intap'
from /home/cis/.rvm/gems/ruby-2.1.2@demo_cache/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:76:in server' from /home/cis/.rvm/gems/ruby-2.1.2@demo_cache/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:40:inrun_command!'
from /home/cis/.rvm/gems/ruby-2.1.2@demo_cache/gems/railties-4.1.5/lib/rails/commands.rb:17:in <top (required)>' from /home/cis/demo_cache/bin/rails:8:inrequire'
from /home/cis/demo_cache/bin/rails:8:in <top (required)>' from /home/cis/.rvm/gems/ruby-2.1.2@demo_cache/gems/spring-1.1.3/lib/spring/client/rails.rb:27:inload'
from /home/cis/.rvm/gems/ruby-2.1.2@demo_cache/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in call' from /home/cis/.rvm/gems/ruby-2.1.2@demo_cache/gems/spring-1.1.3/lib/spring/client/command.rb:7:incall'
from /home/cis/.rvm/gems/ruby-2.1.2@demo_cache/gems/spring-1.1.3/lib/spring/client.rb:26:in run' from /home/cis/.rvm/gems/ruby-2.1.2@demo_cache/gems/spring-1.1.3/bin/spring:48:in<top (required)>'
from /home/cis/.rvm/gems/ruby-2.1.2@demo_cache/gems/spring-1.1.3/lib/spring/binstub.rb:11:in load' from /home/cis/.rvm/gems/ruby-2.1.2@demo_cache/gems/spring-1.1.3/lib/spring/binstub.rb:11:in<top (required)>'
from /home/cis/demo_cache/bin/spring:16:in require' from /home/cis/demo_cache/bin/spring:16:in<top (required)>'
from bin/rails:3:in load' from bin/rails:3:in

'

mobylette_options is nil in "user_agent_excluded?" on jruby

Hallo,
I'm trying to use mobylette 3.3.1 with jruby 1.6.7 (1.9 mode) rails 3.2.9 and jquery-mobile-rails.
In my controller I put the Mobylette include statement and the mobylette_config;
in the controller I added the format.mobile statement in respond_to block and I did create the index.mobile.erb view for my controller.

Every time I run the "index" action I receive an error from rails saying

"undefined method `[]' for nil:NilClass"

The last message in the stack trace is

mobylette (3.3.1) lib/mobylette/respond_to_mobile_requests.rb:162:in `user_agent_excluded?'

After putting rails in debug mode and setting a breakpoint at that line I can see that the mobylette_options variable is nil.
I see that mobylette_options is declared as cattr_accessor in RespondToMobileRequests module,
and from the debugger I can see that @@mobylette_options is correctly filled, while self.mobylette_options is nil.

It seems a problem caused by jruby, because with ruby 1.9.3-p0 this problem does not happen;
I did the same debug and with MRI ruby self.mobylette_options is correctly set.

Samsung Galaxy 3 - SGH-T999 not registering as mobile

I'm viewing with gem 3.3.1 and the site isn't triggering a mobile request.

Mozilla/5.0 (Linux; Android 4.0.4; en-us; SGH-T999 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

add BlackBerry Playbook to mobile devices

Can you please add Blackberry Playbook to the list of default mobile devices?
The user agent string is
Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML, like Gecko) Version/7.2.1.0 Safari/536.2+

I added locally in my gem "playbook" in lib/mobylette/mobile_user_agents.rb and all works ok.

Request format issue with iPad (iPhone working properly)

Hi !

We're using mobylette to handle our mobile device requests under Rails 3.2.2, ruby 1.9.2 app. In our ApplicationController:

  respond_to_mobile_requests :fall_back => :html

It seems mobylette is failing to fallback views for iPads, while properly behaving with iPhones. Here is the error message for a failing iPad request:

ActionView::MissingTemplate: Missing template invitation_requests/new, application/new with {:locale=>[:es], :formats=>[:mobile], :handlers=>[:erb, :builder, :haml]}. Searched in: * "/app/app/views" * "/app/vendor/bundle/ruby/1.9.1/gems/devise-2.0.4/app/views" 

I see a formats => [:mobile] that I guess should include html as well ... just thinking out loud.

Any ideas?

ActionView::FileSystemResolver error while launching server on Rails 4.1.1.

Firstly thanks a lot to all contributors behind this gem, I've already used it on a couple of projects and it always worked like a charm.

However since upgrading to Ruby 2.0.0. and Rails 4.1.1. I've not been able to use it, it makes the whole app crash while running 'rails server' (oh I'm on Windows 8.1, hope it's not related to that...)

Here are the logs:

C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/bundler/gems/mobylette-08781e203eaa/lib/mobylette/resolvers/chained_fallback_resolver.rb:3:in `<module:Resolvers>': uninitialized constant ActionView::FileSystemResolver (NameError)
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/bundler/gems/mobylette-08781e203eaa/lib/mobylette/resolvers/chained_fallback_resolver.rb:2:in `<module:Mobylette>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/bundler/gems/mobylette-08781e203eaa/lib/mobylette/resolvers/chained_fallback_resolver.rb:1:in `<top (required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/bundler/gems/mobylette-08781e203eaa/lib/mobylette.rb:5:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/bundler/gems/mobylette-08781e203eaa/lib/mobylette.rb:5:in `<module:Mobylette>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/bundler/gems/mobylette-08781e203eaa/lib/mobylette.rb:3:in `<top (required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from C:/Users/Raphael/Dropbox/Sites/lacarteimmobiliere/config/application.rb:14:in `<top (required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:79:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:79:in `block in server'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:76:in `tap'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:76:in `server'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

It's referring to this line on application.rb:

Bundler.require(*Rails.groups)

Thank you for any help provided :)

I can't force mobile requesting

Hi tscolari,

First of all, happy new year!!!!

I'm a new on RoR, but I have to mobileze an rails app for a college homework.

I'm training to force mobile requests to test on localhost, but I failed.

Can you give some simple example of where I have to put the code

< session[:mobylette_override] = :force_mobile >

I don't know what is the file that I have to put this command line or when I have to change the value of this variable.

I hope you can help me. I will be sooo thankful.

Happy new year again, congratulations for your great work on mobylette and good luck!

skip_xhr_request doesn't work as expected

I have two controllers.

first_controller:

class FirstController < ApplicationController
  mobylette_config do |config|
    config[:skip_xhr_requests] = false
  end

  def xhr_action1
    ...
  end
end

and second_controler:

class SecondController < ApplicationController
  mobylette_config do |config|
    config[:skip_xhr_requests] = true
  end

  def xhr_action2
    ...
  end
end

Steps to reproduce bug:

  1. Start rails server
  2. Setup mobile user agent (android for example)
  3. Run xhr_action1 of first controller. I see the mobile view and rendering of that action
  4. Then I run xhr_action2 of second_controller and see unified view of xhr_action2
  5. Then I run xhr_action1 of first controller again and I see desktop vie instead of mobile view as I expected.

mobilette set public method to controller

mobilette set public method to controller below:
https://github.com/tscolari/mobylette/blob/master/lib/mobylette/respond_to_mobile_requests.rb#L46

AbstructController calls actions, when action process, check the action included action method.
https://github.com/rails/rails/blob/6033e8a/actionpack/lib/abstract_controller/base.rb#L130
action_methods is important API between ActionDispatch(eg routes) and controller.
Do not define public method in controller exclude action. It should be private method.

Related issue(in japanese sorry):
http://qa.atmarkit.co.jp/q/2700#answer_15280

Clarity on fallback behavior

Gents, I've used mobylette on a few projects over the years and have had a few fallback issues at times -- I think I assumed they were all fixed in 3.x, but ran into a few again. So, first I wanted to start this discussion to see what the expected fallback behavior is.

Gherkin just for clarity...

Given the request for "pages#primary" is a mobile request
And "views/pages/primary.html.haml" exists
And "views/pages/primary.mobile.haml" does NOT exist
And the primary view template renders the "partial" partial
And "views/pages/_partial.html.haml" exists
And "views/pages/_partial.mobile.haml" exists
When the partial is rendered

I would expect the fallback behavior to result in:

Then the "_partial.mobile.haml" file is rendered

However my experience is:
I would expect the fallback behavior to be:

Then the "_partial.html.haml" file is rendered

There are similar behaviors with layout rendering.

What is the desired behavior form your perspective?

Having issue with Devise - mobylette problem or no?

I'm trying to get devise to login but I'm getting a 500 error due to missing template. Any idea? Why is it trying to render devise/sessions/create ?

Rails 3.1

Devise config:
config.navigational_formats = [:"/", "/", :html, :mobile]

--- I noticed this in devise wiki... but it seems that this is exactly what mobylette is doing?

https://github.com/plataformatec/devise/wiki/How-To:-Make-Devise-work-with-other-formats-like-mobile,-iphone-and-ipad-(Rails-specific)

-- Any thoughts?

Completed 500 Internal Server Error in 145msActionView::MissingTemplate (Missing template devise/sessions/create, application/create with {:handlers=>[:erb, :builder, :coffee, :haml], :formats=>[:mobile], :locale=>[:en, :en]}. Searched in: * "/Users/Armageddon/Projects/Business/jquerymobiletest/app/views" * "/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@jquerymobiletest/gems/devise-1.4.9/app/views"): Rendered /Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@jquerymobiletest/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/missing_template.erb within rescues/layout (0.5ms)

Partially Mobile Version

Hi Scolari,

First of all thank you for the GEM, it is really a clever solution.

Concerning the function following,

def is_mobile_request?
true
end

I would like to use the same function "is_mobile_request?" only for a specific controller's action to render the mobile version, and in other cases the non JQuery Mobile layout. Can I use the same function? Or is there any other solution you would prefer?

At the moment, I use it at the application controller then application always renders the mobile version even though I also use bootstrap. As mentioned, I would like to use mobile version partially for a controller's action and the other cases, I would like to use twitter-bootstrap.

Best regards

'method_missing': undefined method 'mobylette_config'

Where should I add these lines?

mobylette_config do |config|
config[:fallback_chains] = { mobile: [:mobile, :html] }
  config[:skip_xhr_requests] = false
  config[:mobile_user_agents] = proc { %r{iphone}i }
end

I tried putting those in development.rb and in new file config/initializers/mobylette.rb, but got 'method_missing': undefined method 'mobylette_config' when starting rails server.

Not able to Sign Out on the Mobile.

I am having a rails application in which I have mobile views. I am able to signup via the mobile but when I am trying to signout then it is rendering me to the root_url.

I've this code "<%= link_to t('link.header.sign_out'), destroy_user_session_path, :method => :delete ,"data-ajax" => "false"%> " for the sign out link in my application.mobile.erb file.

I tried this code without the data-ajax option also but no success.

I am using this gem with Mobylette. and tried the option " respond_to_mobile_requests :skip_xhr_requests => false
" also in ApplicationController but no success.

Template caching

Hello,

This is great gem and we are using it. This gem don't do caching of templates. How can we add support of this in our code.

Regards,
Junaid

mobylette-3.3.2 is incompatible with devise-2 or earlier

I put include Mobylette::RespondToMobileRequests in ApplicationController to handler entire interface to render mobile view. Everything is good, UNLESS after submitting wrong authentication form with DEVISE gem, it would render text only with devise alert message, NO html or mobile view.

could find out, why it happened?

Custom format for ipad and iphone

Hi Tiago & other contributors

I use mobylette in some apps to provide a mobile ready version, but i need to have a custom format for popular devices like ipad and iphone instead of [:mobile] for all devices. I would like to know how to handle that in mobylette.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.