New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use local variables in _form.html.erb generated by scaffold. #13434

Merged
merged 1 commit into from Jan 3, 2015

Conversation

Projects
None yet
8 participants
@tanraya
Contributor

tanraya commented Dec 21, 2013

It seems a good idea to use local variables in generated partials instead of using instance variables.

Before

<%= render 'form' %>

After

<%= render 'form', product: @product %>
# Views local variables
assert_file "app/views/product_lines/_form.html.erb" do |test|
assert_no_match(/@product_line/, test)
end

This comment has been minimized.

@carlosantoniodasilva

carlosantoniodasilva Dec 21, 2013

Member

You can probably remove the _form file from line 66 since we're testing against the same file here again.

@carlosantoniodasilva

carlosantoniodasilva Dec 21, 2013

Member

You can probably remove the _form file from line 66 since we're testing against the same file here again.

This comment has been minimized.

@carlosantoniodasilva

carlosantoniodasilva Dec 21, 2013

Member

Actually nevermind, leave it there.

@carlosantoniodasilva

carlosantoniodasilva Dec 21, 2013

Member

Actually nevermind, leave it there.

@carlosantoniodasilva

This comment has been minimized.

Show comment
Hide comment
@carlosantoniodasilva
Member

carlosantoniodasilva commented Dec 21, 2013

👍

@dmathieu

This comment has been minimized.

Show comment
Hide comment
@dmathieu

dmathieu Dec 22, 2013

Contributor

@tanraya can you squash your commits please? Also, they don't apply cleanly into master. You'll need to rebase.

Contributor

dmathieu commented Dec 22, 2013

@tanraya can you squash your commits please? Also, they don't apply cleanly into master. You'll need to rebase.

@tanraya

This comment has been minimized.

Show comment
Hide comment
@tanraya

tanraya Dec 22, 2013

Contributor

@dmathieu I will do.

Contributor

tanraya commented Dec 22, 2013

@dmathieu I will do.

@tanraya

This comment has been minimized.

Show comment
Hide comment
@tanraya

tanraya Dec 28, 2013

Contributor

@dmathieu done

Contributor

tanraya commented Dec 28, 2013

@dmathieu done

@@ -68,6 +68,17 @@ def test_scaffold_on_invoke
end
assert_no_file "app/views/layouts/product_lines.html.erb"
# Views local variables
assert_file "app/views/product_lines/_form.html.erb" do |test|
assert_no_match(/@product_line/, test)

This comment has been minimized.

@senny

senny Jan 6, 2014

Member

you should verify what should be there, not what shouldn't be there.

@senny

senny Jan 6, 2014

Member

you should verify what should be there, not what shouldn't be there.

This comment has been minimized.

@carlosantoniodasilva

carlosantoniodasilva Jul 28, 2014

Member

👍 for @senny's comment.

@carlosantoniodasilva

carlosantoniodasilva Jul 28, 2014

Member

👍 for @senny's comment.

@jamo

This comment has been minimized.

Show comment
Hide comment
@jamo

jamo Feb 11, 2014

Contributor

I added the suggested test case, see jamo@a0b548d

(all tests passes)

Contributor

jamo commented Feb 11, 2014

I added the suggested test case, see jamo@a0b548d

(all tests passes)

@arunagw

This comment has been minimized.

Show comment
Hide comment
@arunagw

arunagw Jul 4, 2014

Member

@tanraya did you get some time to update this PR?

thanks

Member

arunagw commented Jul 4, 2014

@tanraya did you get some time to update this PR?

thanks

@tanraya

This comment has been minimized.

Show comment
Hide comment
@tanraya

tanraya Jul 25, 2014

Contributor

@arunagw Yes. Updated now.

Contributor

tanraya commented Jul 25, 2014

@arunagw Yes. Updated now.

@arunagw

This comment has been minimized.

Show comment
Hide comment
@arunagw

arunagw Jul 25, 2014

Member

@tanraya seems test broke. Can you see those as well ?

Member

arunagw commented Jul 25, 2014

@tanraya seems test broke. Can you see those as well ?

@carlosantoniodasilva

View changes

Show outdated Hide outdated railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb
Use local variables in _form.html.erb generated by scaffold generator.
It seems a good idea to use local variables in generated partials instead of using instance variables.

Before

    <%= render 'form' %>

After

    <%= render 'form', product: @Product %>
@tanraya

This comment has been minimized.

Show comment
Hide comment
@tanraya

tanraya Jul 26, 2014

Contributor

@carlosantoniodasilva @arunagw Now its done. All tests passed.

Contributor

tanraya commented Jul 26, 2014

@carlosantoniodasilva @arunagw Now its done. All tests passed.

@rafaelfranca rafaelfranca modified the milestones: 4.2.0, 5.0.0 Aug 18, 2014

carlosantoniodasilva added a commit that referenced this pull request Jan 3, 2015

Merge pull request #13434 from tanraya/local_variables
Use local variables in _form.html.erb generated by scaffold.

Conflicts:
	railties/CHANGELOG.md

carlosantoniodasilva added a commit that referenced this pull request Jan 3, 2015

@carlosantoniodasilva carlosantoniodasilva merged commit 6bd8126 into rails:master Jan 3, 2015

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details

@rafaelfranca rafaelfranca modified the milestones: 5.0.0 [temp], 5.0.0 Dec 30, 2015

prathamesh-sonpatki added a commit to prathamesh-sonpatki/rails that referenced this pull request Jun 11, 2016

christiannelson added a commit to carbonfive/raygun-rails that referenced this pull request Jul 1, 2016

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