aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/mime_responds.rb
Commit message (Collapse)AuthorAgeFilesLines
* No variant should also be picked up by variant.any if variant.none is not ↵David Heinemeier Hansson2014-02-131-1/+1
| | | | defined (just like any other variant)
* Variant negotiationLukasz Strzalkowski2014-02-131-8/+20
| | | | | | | | | | | | | | Allow setting `request.variant` as an array - an order in which they will be rendered. For example: request.variant = [:tablet, :phone] respond_to do |format| format.html.none format.html.phone # this gets rendered end
* Add any/all support for variantsŁukasz Strzałkowski2013-12-261-27/+54
| | | | | | | | | | | | | | | | | | | | Like `format.any`, you can do the same with variants. It works for both inline: respond_to do |format| format.html.any { render text: "any" } format.html.phone { render text: "phone" } end and block syntax: respond_to do |format| format.html do |variant| variant.any(:tablet, :phablet){ render text: "any" } variant.phone { render text: "phone" } end end
* Some assorted fixes for the 4.1 release notes:Godfrey Chan2013-12-171-1/+1
| | | | | | | | | | | * Added release notes for secrets.yml and mentioned it in the highlights * Added release notes for Mailer previews and mentioned it in the highlights * Added release notes for Module#concerning * Removed mention for AV extraction from the highlights * Rearranged the major features to put highlighted features first * Various improvements and typo fixes [ci skip]
* Variants inline syntax documentation [ci skip]Łukasz Strzałkowski2013-12-121-0/+9
| | | | | | * Extend method documentation * Mention it in actionpack/CHANGELOG * Update release notes
* Inline variants syntaxŁukasz Strzałkowski2013-12-101-2/+24
| | | | | | | | | | | | | | | | | | | | | | | In most cases, when setting variant specific code, you're not sharing any code within format. Inline syntax can vastly simplify defining variants in those situations: respond_to do |format| format.js { render "trash" } format.html do |variant| variant.phone { redirect_to progress_path } variant.none { render "trash" } end end Becomes: respond_to do |format| format.js { render "trash" } format.html.phone { redirect_to progress_path } format.html.none { render "trash" } end
* Simplify @responses hash initializationŁukasz Strzałkowski2013-12-101-1/+2
| | | | | | | | | | | | | @responses hash needs to be initialized with mime types that we get from Collector#collect_mimes_from_class_level. Mime::Type class as key and nil as value. This need to happen before content negotiation. Before that, it was looping though mime types and executing mime-type-generated method inside collector (see AbstractController::Collector#generate_method_for_mime). That approach resulted in 2 unnecessary method calls for each mime type collected by Collector#collect_mimes_from_class_level. Now hash is initialized in place, without usage of Collector#custom method.
* Revert "Merge pull request #13235 from strzalek/variants-inline" -- needs a ↵David Heinemeier Hansson2013-12-081-15/+9
| | | | | | | little more work! This reverts commit 186161148a189839a1e0924043f068a8d155ce69, reversing changes made to cad9eb178ea5eec0e27d74e93518f4ed34e2f997.
* Inline variants syntaxŁukasz Strzałkowski2013-12-081-8/+14
| | | | | | | | | | | | | | | | | | | | | | | In most cases, when setting variant specific code, you're not sharing any code within format. Inline syntax can vastly simplify defining variants in those sitiations: respond_to do |format| format.js { render "trash" } format.html do |variant| variant.phone { redirect_to progress_path } variant.none { render "trash" } end end ` Becomes: respond_to do |format| format.js { render "trash" } format.html.phone { redirect_to progress_path } format.html.none { render "trash" } end
* Simplify @responses hash initializationŁukasz Strzałkowski2013-12-081-1/+1
| | | | | | | | | | | | | @responses hash needs to be initialized with mime types that we get from Collector#collect_mimes_from_class_level. Mime::Type class as key and nil as value. This need to happen before content negotiation. Before that, it was looping though mime types and executing mime-type-generated method inside collector (see AbstractController::Collector#generate_method_for_mime). That approach resulted in 2 unnecessary method calls for each mime type collected by Collector#collect_mimes_from_class_level. Now hash is initialized in place, without usage of Collector#custom method.
* Variants can be declared without a block to signify their presence in the ↵David Heinemeier Hansson2013-12-071-1/+3
| | | | controller
* Allow code execution in case no variant has been set with variant.noneDavid Heinemeier Hansson2013-12-071-4/+5
|
* Improve a couple exception messages related to variants and mime typesCarlos Antonio da Silva2013-12-031-2/+4
| | | | | Avoid one-liner conditionals when they are too big. Avoid concatenating strings to build error messages. Improve messages a bit.
* Add nodoc to added VariantFilter classCarlos Antonio da Silva2013-12-031-3/+3
|
* Action Pack VariantsŁukasz Strzałkowski2013-12-041-4/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Revert "Used Yield instead of block.call" -- this causes all of ↵David Heinemeier Hansson2013-11-141-2/+2
| | | | | | atom_feed_helper_test.rb to fail with "SystemStackError: stack level too deep". This reverts commit d3a1ce1cdc60d593de1682c5f4e3230c8db9a0fd.
* Merge pull request #12889 from kuldeepaggarwal/speed_upsRafael Mendonça França2013-11-141-2/+2
|\ | | | | Used Yield instead of block.call
| * Used Yield instead of block.callKuldeep Aggarwal2013-11-151-2/+2
| |
* | Remove order attribute from collectorLukasz Strzalkowski2013-11-101-4/+3
|/ | | | Ruby 1.8 legacy. Since 1.9 hash preserves insertion order. No need for additional array to achieve this
* Fixing repond_with working directly on the options hashBlueHotDog2013-10-091-0/+1
| | | | | | | | This fixes an issue where the respond_with worked directly with the given options hash, so that if a user relied on it after calling respond_with, the hash wouldn't be the same. Fixes #12029
* Remove remaining coupling with AV in MimeRespondsJosé Valim2013-09-091-3/+1
|
* fix respond_to without blocks not working if one of the blocks is allgrosser2013-02-241-1/+1
|
* Missing or unneeded require extract_optionsAkira Matsuda2013-02-011-0/+1
|
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-01-091-4/+4
|\ | | | | | | | | Conflicts: guides/source/getting_started.md
| * PUT => PATCHAkira Matsuda2013-01-031-1/+1
| |
| * find_or_create_by is deprecated in AR 4Akira Matsuda2013-01-021-3/+3
| |
* | Reduce number of Strings a bitAkira Matsuda2013-01-071-1/+1
|/
* Multiple changes to 1,9 hash syntaxAvnerCohen2012-10-271-12/+12
|
* removes usage of Object#in? from the code base (the method remains defined ↵Xavier Noria2012-08-061-2/+2
| | | | | | | | | | | | | | | | | | | by Active Support) Selecting which key extensions to include in active_support/rails made apparent the systematic usage of Object#in? in the code base. After some discussion in https://github.com/rails/rails/commit/5ea6b0df9a36d033f21b52049426257a4637028d we decided to remove it and use plain Ruby, which seems enough for this particular idiom. In this commit the refactor has been made case by case. Sometimes include? is the natural alternative, others a simple || is the way you actually spell the condition in your head, others a case statement seems more appropriate. I have chosen the one I liked the most in each case.
* load active_support/core_ext/class/attribute in active_support/railsXavier Noria2012-08-021-1/+0
|
* load active_support/core_ext/object/inclusion in active_support/railsXavier Noria2012-08-021-1/+0
|
* copy-edits 9674d2cXavier Noria2012-07-211-2/+2
|
* Clarification to doc of ActionController::MimeResponse.respond_toShigeya Suzuki2012-07-191-1/+2
| | | | | - #respond_to's documentation refer to .respond_to, but it was written as just <respond_to>. Added class name for clarification.
* Removing ==Examples and last blank lines of docs from actionpackFrancesco Rodriguez2012-05-151-7/+0
|
* remove .new from raise ActionController::UnknownFormatSteven Soroka2012-05-061-1/+1
|
* Raise a rescuable exception when Rails doesn't know what to do with the ↵Steven Soroka2012-05-061-2/+1
| | | | format, rather than responding with a head :not_acceptable (406)
* Remove non-obligatory params in AC respond_to examplesAlexey Vakhov2012-04-031-2/+2
|
* respond_with description: changed 'response' to 'format'Mark Thomson2012-03-181-1/+1
|
* Revised comments for respond_withMark Thomson2012-03-181-17/+18
|
* Merge remote-tracking branch 'origin/master'Mark Thomson2012-03-171-2/+6
|\
| * Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-03-131-1/+24
| |\
| * | Updated description of #retrieve_collector_from_mimesMark Thomson2012-03-131-2/+6
| | |
* | | Revised description for responds_withMark Thomson2012-03-171-19/+115
| |/ |/|
* | Added documentation for the ActionController::MimeResponds::Collector class.Mark Thomson2012-03-131-1/+24
|/
* Set the rendered_format on respond_to.José Valim2012-03-071-0/+1
|
* Avoid ImplicitRender just call render directlySantiago Pastorino2012-03-061-3/+1
|
* Always passing a respond block from to responderPrem Sichanugrist2012-03-051-10/+2
| | | | | | | We should let the responder to decide what to do with the given overridden response block, and not short circuit it. Fixes #5280
* remove usages of AS::OrderedHashVishnu Atrai2012-03-031-1/+1
|
* format lookup for partials is derived from the format in which the template ↵Santiago Pastorino2012-02-221-1/+1
| | | | | | is being rendered Closes #5025 part 2
* Clean up a bit default_response handling and cache format negotiation.José Valim2012-02-041-17/+16
|