Skip to content
Mobvious extensions for Rails views, controllers and CoffeeScript
Ruby CoffeeScript
Find file
Latest commit 759a222 Apr 10, 2012 @jistr readme fix
Failed to load latest commit information.
app/assets/javascripts coffeescript helpers - multiple device types can be specified in for_… Feb 22, 2012
lib/mobvious version bump Apr 2, 2012
spec spec that coffeescript for_device_type block should run only once Mar 13, 2012
.gitignore
.yardopts gitignore and options for YARD Feb 20, 2012
Gemfile development deps tweaks Feb 20, 2012
Guardfile comment on the double test run Feb 22, 2012
LICENSE license and blank readme Mar 13, 2012
README.md
Rakefile rake task for testing, using require_relative in specs Mar 13, 2012
mobvious-rails.gemspec changes to enable coffeescript testing + passing tests Feb 22, 2012

README.md

Mobvious-Rails

Mobvious extensions for Rails views, controllers and CoffeeScript

Key Features

  • Access detected device type easily from controllers and views. Just write device_type.

  • Execute code for given device types only. Both in controllers and views.

    <% for_device_type :mobile do %>
      <%= stylesheet_link_tag 'mobile_styles' %>
    <% end %>
    
  • Do the above stuff also in your CoffeeScript.

    alert 'You are using a ' + Mobvious.device_type + ' device.'
    
    Mobvious.for_device_type 'mobile', ->
      alert 'You are using a mobile device.'
    

Get Started

  1. Include the gem in your Gemfile.
    For Bundler >= 1.1: gem 'mobvious-rails'
    For Bundler < 1.1: gem 'mobvious-rails', require: 'mobvious/rails'

  2. Include modules to your controllers and helpers. No sneaky monkey patching in Mobvious!

    Put this into your ApplicationController:

    include Mobvious::Rails::Controller
    

    And this into your ApplicationHelper:

    include Mobvious::Rails::Helper
    
  3. Optionally, include also CoffeeScript helpers.

    Put this into your layouts/application.html.erb:

    <head>
      <%= mobvious_javascript %>
      <!-- other code here -->
    </head>
    

    And this into your application.js:

    //= require mobvious-rails
    

That's it! You can now use all the stuff. See the documentation if necessary.

Something went wrong with that request. Please try again.