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

Add docs about local_assigns on guides #15700

Merged
merged 2 commits into from Feb 18, 2015

Conversation

Projects
None yet
6 participants
@maurogeorge
Contributor

maurogeorge commented Jun 13, 2014

No description provided.

Show outdated Hide outdated guides/source/layouts_and_rendering.md
@@ -1069,6 +1069,36 @@ You can also pass local variables into partials, making them even more powerful
Although the same partial will be rendered into both views, Action View's submit helper will return "Create Zone" for the new action and "Update Zone" for the edit action.
When we need to pass a local variable to partial in only specific cases we can use the `local_assigns` to check for a defined local variable.

This comment has been minimized.

@rafaelfranca

rafaelfranca Jun 13, 2014

Member

I think this is a little confusing maybe you could use some punctuation to make it more clear.

@rafaelfranca

rafaelfranca Jun 13, 2014

Member

I think this is a little confusing maybe you could use some punctuation to make it more clear.

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Jun 13, 2014

Member

@maurogeorge we need document local_assigns as public API first (to appear at api.rubyonrails.com). Right now it only work because it is an instance variable in the scope the view is compiled.

We should use Rdoc to make it available there doing something like this https://github.com/rails/rails/blob/master/actionpack/lib/abstract_controller/callbacks.rb#L80-85

Member

rafaelfranca commented Jun 13, 2014

@maurogeorge we need document local_assigns as public API first (to appear at api.rubyonrails.com). Right now it only work because it is an instance variable in the scope the view is compiled.

We should use Rdoc to make it available there doing something like this https://github.com/rails/rails/blob/master/actionpack/lib/abstract_controller/callbacks.rb#L80-85

@cristianbica

This comment has been minimized.

Show comment
Hide comment
@cristianbica

cristianbica Feb 17, 2015

Member

@maurogeorge @rafaelfranca as local_assigns is a local variable in that function documenting that local variable doesn't feel ok. I think we should save the data in an instance variable and provide a helper to access it and then we can provide real documentation. WDYT?

Member

cristianbica commented Feb 17, 2015

@maurogeorge @rafaelfranca as local_assigns is a local variable in that function documenting that local variable doesn't feel ok. I think we should save the data in an instance variable and provide a helper to access it and then we can provide real documentation. WDYT?

@dhh

This comment has been minimized.

Show comment
Hide comment
@dhh

dhh Feb 17, 2015

Member

local_assigns is very helpful in a number of cases. I just started depending on that in my app. Using defined? is just annoying as hell. So let's definitely make the local_assigns API public and commit to it.

Member

dhh commented Feb 17, 2015

local_assigns is very helpful in a number of cases. I just started depending on that in my app. Using defined? is just annoying as hell. So let's definitely make the local_assigns API public and commit to it.

@arthurnn arthurnn added the docs label Feb 17, 2015

@jrochkind

This comment has been minimized.

Show comment
Hide comment
@jrochkind

jrochkind Feb 17, 2015

Contributor

Thanks, I find local_assigns useful too, and was scared that it was maybe no longer public API, as the one mention of it from public docs had been removed (3dfcae6, thanks @nithinbekal for noticing that commit where it was removed; they also have a doc PR on this at #18970)

I think there are lots of apps using it (and it used to be mentioned in docs), so at minimum it probably should be considered public API already until deprecated and removed according to whatever Rails policies are for backwards compat. But really, I'd prefer it simply remain public API.

+1

Contributor

jrochkind commented Feb 17, 2015

Thanks, I find local_assigns useful too, and was scared that it was maybe no longer public API, as the one mention of it from public docs had been removed (3dfcae6, thanks @nithinbekal for noticing that commit where it was removed; they also have a doc PR on this at #18970)

I think there are lots of apps using it (and it used to be mentioned in docs), so at minimum it probably should be considered public API already until deprecated and removed according to whatever Rails policies are for backwards compat. But really, I'd prefer it simply remain public API.

+1

@rafaelfranca rafaelfranca merged commit 9999dc9 into rails:master Feb 18, 2015

rafaelfranca added a commit that referenced this pull request Feb 18, 2015

Merge pull request #15700 from maurogeorge/guides-local_assigns
Add docs about local_assigns on guides
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment