问题
I was trying to create an action for one of the partials in my rails application, but wondered how to name it. Does it have the underscore at the beginning? Like:
def _my_partial
end
or no underscore? Not mentioned in the controllers guide
回答1:
A partial
is a piece of view which is embedded in the main view or within another partial
. The purpose of a partial
is typically for re-use or to making view code cleaner.
If you need to use an action to render a partial, then it's probably better to either:
- make your partial into a view, or
- create a view to embed your partial. See Rails 4 - passing variable to partial
来源:https://stackoverflow.com/questions/28268659/controller-action-for-partials