Add docs about local_assigns on guides #15700

merged 2 commits into from Feb 18, 2015


None yet

6 participants


No description provided.

@rafaelfranca rafaelfranca commented on an outdated diff Jun 13, 2014
@@ -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.
rafaelfranca Jun 13, 2014 Member

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


@maurogeorge we need document local_assigns as public API first (to appear at 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


@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 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

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.


@rafaelfranca rafaelfranca merged commit 9999dc9 into rails:master Feb 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment