Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix for external generators extend Erb::Generators #14132

Closed
wants to merge 5 commits into from

7 participants

@afair

HAML and probably other generators extend this class and invoke filename_with_extensions with the old signature (without format). This makes the second argument optional and defaults it to the #format method which could be overridden as well.

@afair afair Fix for external generators extend Erb::Generators
HAML and probably other generators extend this class and invoke filename_with_extensions with the old signature (without format). This makes the second argument optional and defaults it to the #format method which could be overridden as well.
38c9de7
@afair

The problem occurs with Rails 4.1.0.rc1 with haml-rails 0.5.3. Rails 4.1.0.beta1 did not have the problem.

@indirect indirect referenced this pull request in indirect/haml-rails
Closed

Error generating view with Rails 4.1 #66

railties/lib/rails/generators/erb.rb
@@ -17,8 +17,8 @@ def handler
:erb
end
- def filename_with_extensions(name, format)
- [name, format, handler].compact.join(".")
+ def filename_with_extensions(name, format_override=nil)
@arthurnn Collaborator

how about we do this instead:

def filename_with_extensions(name, format_override=self.format)

So we wont need the || check in the next line

@afair
afair added a note

Great, I didn't know you could set a default with a method call. I'll update it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mdesantis

It breaks Slim too, FYI

@mdesantis mdesantis referenced this pull request in slim-template/slim-rails
Closed

Rails 4.1 #40

@robin850 robin850 added this to the 4.1.0 milestone
@razum2um

breaks rabl-generators as well

railties/lib/rails/generators/erb.rb
@@ -17,8 +17,8 @@ def handler
:erb
end
- def filename_with_extensions(name, format)
- [name, format, handler].compact.join(".")
+ def filename_with_extensions(name, format_override=self.format)

Minor thing: please add space surrounding =, and I believe you don't need to use self since you are using a different variable name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@carlosantoniodasilva

Is there a way to provide a minor test case so that we ensure won't break it again? Thanks.

@kevinelliott

:+1: for this fix.

afair added some commits
@afair afair Adds regression test for filename_with_extensions default
Also renames the format_override to simply format in the fix.
99fd155
@afair afair Reverts test case
The test case did not work. I don't know how to isolate this as a test.

Can anyone help?
51f7de8
@afair afair Formatting change to trigger CI
Previous build failed with a memcache issue on one run. I couldn't find
how to trigger this to run again without a push.
025a26b
@carlosantoniodasilva carlosantoniodasilva closed this pull request from a commit
@afair afair Fix for external generators extend Erb::Generators
HAML and probably other generators extend this class and invoke
filename_with_extensions with the old signature (without format).
This makes the second argument optional and defaults it to the #format
method which could be overridden as well.

Closes #14132.
3624ff7
@carlosantoniodasilva carlosantoniodasilva referenced this pull request from a commit
@afair afair Fix for external generators extend Erb::Generators
HAML and probably other generators extend this class and invoke
filename_with_extensions with the old signature (without format).
This makes the second argument optional and defaults it to the #format
method which could be overridden as well.

Closes #14132.
4ca8180
@ttosch ttosch referenced this pull request from a commit
@afair afair Fix for external generators extend Erb::Generators
HAML and probably other generators extend this class and invoke
filename_with_extensions with the old signature (without format).
This makes the second argument optional and defaults it to the #format
method which could be overridden as well.

Closes #14132.
2e55c93
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 20, 2014
  1. @afair

    Fix for external generators extend Erb::Generators

    afair authored
    HAML and probably other generators extend this class and invoke filename_with_extensions with the old signature (without format). This makes the second argument optional and defaults it to the #format method which could be overridden as well.
Commits on Feb 21, 2014
  1. @afair
Commits on Feb 27, 2014
  1. @afair

    Adds regression test for filename_with_extensions default

    afair authored
    Also renames the format_override to simply format in the fix.
  2. @afair

    Reverts test case

    afair authored
    The test case did not work. I don't know how to isolate this as a test.
    
    Can anyone help?
Commits on Feb 28, 2014
  1. @afair

    Formatting change to trigger CI

    afair authored
    Previous build failed with a memcache issue on one run. I couldn't find
    how to trigger this to run again without a push.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  railties/lib/rails/generators/erb.rb
View
2  railties/lib/rails/generators/erb.rb
@@ -17,7 +17,7 @@ def handler
:erb
end
- def filename_with_extensions(name, format)
+ def filename_with_extensions(name, format=self.format)
[name, format, handler].compact.join(".")
end
end
Something went wrong with that request. Please try again.