And then in the application.html.erb have an IF to not add a padding
class if :padding is false… But the above idea doesn’t work, the
variable padding is not being passed.
Add one more stylesheet in every view that needs padding:
#application.html.erb layout
<%= yield :head %>
#new.html.erb
content_for(:head) do
stylesheet_link_tag ‘padding’
end
You could abstract it into helper method and use as simple as: #new.html.erb
<%= padding() %>
Third way is to create helper that would be used this way:
<%= padding do %>
create your content here
<% end %>
I wouldn’t bother controller with such a minor change in view layer so
I prefere keeping padding in views instead changing layout on the
controller side.