1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/test/fixtures
Łukasz Strzałkowski 2d3a6a0cb8 Action Pack Variants
By default, variants in the templates will be picked up if a variant is set
and there's a match. The format will be:

  app/views/projects/show.html.erb
  app/views/projects/show.html+tablet.erb
  app/views/projects/show.html+phone.erb

If request.variant = :tablet is set, we'll automatically be rendering the
html+tablet template.

In the controller, we can also tailer to the variants with this syntax:

  class ProjectsController < ActionController::Base
    def show
      respond_to do |format|
        format.html do |html|
          @stars = @project.stars

          html.tablet { @notifications = @project.notifications }
          html.phone  { @chat_heads    = @project.chat_heads }
        end

        format.js
        format.atom
      end
    end
  end

The variant itself is nil by default, but can be set in before filters, like
so:

  class ApplicationController < ActionController::Base
    before_action do
      if request.user_agent =~ /iPad/
        request.variant = :tablet
      end
    end
  end

This is modeled loosely on custom mime types, but it's specifically not
intended to be used together. If you're going to make a custom mime type,
you don't need a variant. Variants are for variations on a single mime
types.
2013-12-04 00:13:16 +01:00
..
alternate_helpers Use redefine_method since baz is already defined. 2010-09-28 18:31:52 -03:00
bad_customers
filter_test/implicit_actions Add a failing test case for an implicit action with a before filter. 2011-03-23 23:32:44 +00:00
functional_caching Add explicit opt-out for fragment cache digesting 2012-11-25 22:10:44 -06:00
helpers Remove HelperyTestHelper not used in any test 2013-09-14 10:40:28 -07:00
helpers1_pack Fix sorting of helpers from different paths 2012-05-28 06:58:48 +02:00
helpers2_pack Fix sorting of helpers from different paths 2012-05-28 06:58:48 +02:00
layouts Remove unneeded test fixtures in AV 2013-06-20 17:23:16 +02:00
localized Fix header Content-Type: #<Mime::NullType:...> in localized template 2013-12-03 07:46:39 +01:00
multipart UTF-8 encode all keys and values in nested params hash. 2013-03-15 09:17:03 +08:00
old_content_type removes the RJS template handler 2011-04-13 13:23:18 +02:00
post_test
public Remove unneeded test fixtures in AV 2013-06-20 17:23:16 +02:00
respond_to Action Pack Variants 2013-12-04 00:13:16 +01:00
respond_with Fixing repond_with working directly on the options hash 2013-10-09 12:36:26 +03:00
session_autoload_test/session_autoload_test Fixed that an ArgumentError is thrown when request.session_options[:id] is read in the following scenario: when the cookie store is used, and the session contains a serialized object of an unloaded class, and no session data accesses have occurred yet. Pushed the stale_session_check responsibility out of the SessionHash and down into the session store, closer to where the deserialization actually occurs. Added some test coverage for this case and others related to deserialization of unloaded types. 2010-06-27 22:39:06 +02:00
star_star_mime add the fixture file 2010-11-22 23:06:13 +01:00
symlink_parent
test Remove unneeded test fixtures in AV 2013-06-20 17:23:16 +02:00
_top_level_partial_only.erb
company.rb Remove integration between attr_accessible/protected and AC::Metal::ParamsWrapper 2012-09-16 23:58:20 -05:00
ruby_template.ruby Rename .rb template handler to .ruby to avoid conflicts with mustache views classes 2012-09-17 10:07:08 -05:00
shared.html.erb