There is a short form for writing partials. So the following:
<%= render partial: '/pages/forms/refresh_counter', locals: {counter: @refresh_counter} %>
Can be written:
<%= render '/pages/forms/refresh_counter', counter: @refresh_counter %>
You can omit the trailing slash
<%= render 'pages/forms/refresh_counter', counter: @refresh_counter %>
Since the controller is pages rails can infer this but it can only do this for top-level partials.
pages
So this wouldn't work
<%= render 'forms/refresh_counter', counter: @refresh_counter %>
But this would.
<%= render 'forms_refresh_counter', counter: @refresh_counter %>
You would think you could use a symbol because you can in your controller for when you can call render:
PagesController < ApplicationController def show render :show end
But it cannot be done with partials. I thought you could before but I think I am mistaken.
<%= render :forms_refresh_counter, counter: @refresh_counter %>
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
There is a short form for writing partials. So the following:
Can be written:
You can omit the trailing slash
Since the controller is
pages
rails can infer this but it can only do this for top-level partials.So this wouldn't work
But this would.
You would think you could use a symbol because you can in your controller for when you can call render:
But it cannot be done with partials. I thought you could before but I think I am mistaken.