Commit Graph

10750 Commits

Author SHA1 Message Date
Rafael Mendonça França
108171a44e Merge pull request #13307 from akshay-vishnoi/typo
Spelling and Grammar check [ci skip]
2013-12-15 11:19:44 -08:00
Akshay Vishnoi
c758093eca Spelling and Grammar check [ci skip] 2013-12-16 00:44:37 +05:30
robertomiranda
35d0d6fec5 Update secret_key_base Docs 2013-12-15 10:32:41 -05:00
Philipe Fatio
fd76b9d546 Fix syntax error in redirect_to example
Without parenthesis, ruby assumes that curly braces denote the beginning
of a block.
2013-12-14 15:35:50 +01:00
Carlos Antonio da Silva
07fd25c759 Merge pull request #13293 from akshay-vishnoi/typo
Spelling and Grammar checks [ci skip]
2013-12-12 08:12:13 -08:00
Rafael Mendonça França
1454f2c20a Merge pull request #13290 from strzalek/inline-syntax-docs
Variants inline syntax documentation
2013-12-12 07:59:17 -08:00
Akshay Vishnoi
5fccd77b6c Spelling and Grammar checks 2013-12-12 18:28:34 +05:30
Łukasz Strzałkowski
3ce9563d42 Variants inline syntax documentation [ci skip]
* Extend method documentation
  * Mention it in actionpack/CHANGELOG
  * Update release notes
2013-12-12 13:20:45 +01:00
Carlos Antonio da Silva
fe24f3560a Changelog improvements [ci skip] 2013-12-12 08:33:46 -02:00
Damien Mathieu
6645a2099a Merge pull request #13288 from dvsuresh/fix_typo
Fix typo in action_controller responder.rb [ci skip]
2013-12-12 00:13:52 -08:00
dvsuresh
25a5c5f236 Fix typo in action_controller responder.rb 2013-12-12 02:03:58 -06:00
Godfrey Chan
ebfd97124d Merge pull request #13284 from aayushkhandelwal11/typos_corrected
s/everytime/every time/
2013-12-11 22:13:04 -08:00
Aayush khandelwal
4a9e54ef35 typos rectified [ci skip] 2013-12-12 11:29:23 +05:30
Trent Ogren
96a6703ed9 Update CHANGELOG entry for Session#fetch
This reverts the changes to CHANGELOG.md in commit
38f8872aa5fd8f0a1d0895e9eb41f73261acd040.
2013-12-11 19:26:45 -06:00
Trent Ogren
d0fc760d09 Make ActionDispatch::Request::Session#fetch behave like Hash#fetch
Session#fetch was mutating the session when given a default argument
and/or a block. Since Session duck-types as a Hash, it should behave
like one in these cases.
2013-12-11 15:29:33 -06:00
Piotr Sarnacki
e6c602da90 Fix mounting engines inside a resources block
When a route is mounted inside a resources block, it's automatically
prefixed, so a following code:

    resources :users do
      mount Blog::Engine => '/blog'
    end

will generate a user_blog path helper.

In order to access engine helpers, we also use "mounted_helpers", a list
of helpers associated with each mounted engine, so a path to blog's post
can be generated using user_blog.post_path(user, post).

The problem I'm fixing here is that mount used a raw :as option, without
taking nestings into account. As a result, blog was added to a route set
as a `user_blog`, but helper was generated for just `blog`.

This commit applies the proper logic for defining a helper for a mounted
engine nested in resources or resource block.

(closes #8533)
2013-12-10 21:38:41 +01:00
Łukasz Strzałkowski
edacdbfaf9 Inline variants syntax
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
2013-12-10 11:55:43 +01:00
Łukasz Strzałkowski
fbb6be50a5 Simplify @responses hash initialization
@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.
2013-12-10 11:47:50 +01:00
David Heinemeier Hansson
4aae538d9f Revert "Merge pull request #13235 from strzalek/variants-inline" -- needs a little more work!
This reverts commit 186161148a189839a1e0924043f068a8d155ce69, reversing
changes made to cad9eb178ea5eec0e27d74e93518f4ed34e2f997.
2013-12-08 14:04:04 -08:00
David Heinemeier Hansson
186161148a Merge pull request #13235 from strzalek/variants-inline
Inline syntax for variants
2013-12-08 13:38:01 -08:00
Łukasz Strzałkowski
2647d2f656 Inline variants syntax
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
2013-12-08 22:29:07 +01:00
Łukasz Strzałkowski
9b8c0ff391 Simplify @responses hash initialization
@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.
2013-12-08 22:11:46 +01:00
Łukasz Strzałkowski
d99dd0af03 Require action_view explicitly in AC::Base 2013-12-08 13:03:41 +01:00
David Heinemeier Hansson
99975e742e Variants can be declared without a block to signify their presence in the controller 2013-12-07 16:32:38 -08:00
David Heinemeier Hansson
a16fa9abfd Allow code execution in case no variant has been set with variant.none 2013-12-07 15:00:35 -08:00
Arun Agrawal
7f10232b9e Fixed test for Mime::VCF
Added here 13dd38cee79be39f7b399e142fd78295dddd2abb
2013-12-06 08:15:43 +01:00
David Heinemeier Hansson
13dd38cee7 Add Mime::Type.register "text/vcard", :vcf to the default list of mime types 2013-12-05 15:49:06 -08:00
Jeremy Kemper
5086c8c211 Merge pull request #13189 from strzalek/retain-ap-av-dep
Retain ActionPack dependency on ActionView. Fixes #12979.
2013-12-05 07:25:17 -08:00
Yves Senn
d71c1fc6a7 add missing CHANGELOG entry for d8c6f52. [ci skip]
Discoverd by #13175.
2013-12-05 11:41:12 +01:00
Carlos Antonio da Silva
d6eda3ef3c Remove missing integration points of AV extraction 2013-12-05 11:39:56 +01:00
Shota Fukumori (sora_h)
c1d5477b63 Escalate missing error when :raise is true
Before ec16ba75a5493b9da972eea08bae630eba35b62f,
ActionView::Helpers::TranslationHelper#translate has raised errors with
specifying options[:raise] to true.

This should work by this fix:

     begin
       t(:"translations.missing", raise: true)
     rescue I18n::MissingTranslationData
       p :hello!
     end
2013-12-05 09:20:58 +09:00
Łukasz Strzałkowski
d8888b94b3 Retain ActionPack dependency on ActionView 2013-12-05 01:02:46 +01:00
Rafael Mendonça França
2d061c2c4f Update changelog [ci skip] 2013-12-04 17:48:32 -02:00
Angelo capilleri
2f3fe92f1b remove nil in NullType#ref.
Return Nil is implicit in a method and this syntax is used in the others
classes
2013-12-04 17:55:05 +01:00
Carlos Antonio da Silva
3b40a5d83d Improve a couple exception messages related to variants and mime types
Avoid one-liner conditionals when they are too big. Avoid concatenating
strings to build error messages. Improve messages a bit.
2013-12-03 22:23:12 -02:00
Carlos Antonio da Silva
bc26f442d2 Add nodoc to added VariantFilter class 2013-12-03 22:08:18 -02:00
Ł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
Carlos Antonio da Silva
ce148025f2 Change deep_munge call to avoid deprecation warning 2013-12-03 20:25:03 -02:00
Aaron Patterson
dba82120fe Merge branch 'master-sec'
* master-sec:
  Deep Munge the parameters for GET and POST
  Stop using i18n's built in HTML error handling.
  Ensure simple_format escapes its html attributes
  Escape the unit value provided to number_to_currency
  Only use valid mime type symbols as cache keys
2013-12-03 11:01:56 -08:00
Carlos Antonio da Silva
7c20a8b558 Changelog improvements [ci skip] 2013-12-03 14:38:12 -02:00
Guillermo Iguaran
abc1e5831c Convert Mime::NullType in a singleton 2013-12-03 02:41:26 -05:00
Guillermo Iguaran
66b1c2d3b5 Cleanups in comment about conditional 2013-12-03 02:34:57 -05:00
Guillermo Iguaran
9ed3aab692 Merge branch 'format_localized_template' of https://github.com/acapilleri/rails
Conflicts:
	actionpack/CHANGELOG.md
2013-12-03 02:34:11 -05:00
Angelo capilleri
43962d6ec5 Fix header Content-Type: #<Mime::NullType:...> in localized template
This PR fixes #13064 regression bug introduced by the #8085

Now in _process_format when the format is a Mime::NullType nothing is written in self.content_type.
In this way the method Response#assign_default_content_type_and_charset can
write the the default mime_type.
2013-12-03 07:46:39 +01:00
Michael Koziarski
4e9dd5378b Deep Munge the parameters for GET and POST
The previous implementation of this functionality could be accidentally
subverted by instantiating a raw Rack::Request before the first Rails::Request
was constructed.

Fixes CVE-2013-6417
2013-12-02 16:44:27 -08:00
Carlos Antonio da Silva
45f70dca7b Merge pull request #12123 from aredondo/master
Add regression test for IpSpoofAttackError issue

Closes #10780
2013-12-02 16:23:45 -08:00
Genadi Samokovarov
6329d9fa8b Remove deprecated cattr_* requires 2013-12-03 00:28:15 +02:00
Andrew White
d2e1caaab9 Try to escape each part of a path redirect route correctly
A path redirect may contain any and all parts of a url which have different
escaping rules for each part. This commit tries to escape each part correctly
by splitting the string into three chunks - path (which may also include a host),
query and fragment; then it applies the correct escape pattern to each part.

Whilst using `URI.parse` would be better, unfortunately the possible presence
of %{name} parameters in the path redirect string prevents us from using it so
we have to use a regular expression instead.

Fixes #13110.
2013-12-02 05:16:05 +00:00
Tejas Dinkar
223ff7949e [ci skip] Removing some gender sensitive object pronouns 2013-12-02 09:24:47 +05:30
Guillermo Iguaran
49ff20d9b1 Use genderless pronouns in API docs 2013-12-01 03:20:39 -05:00