Rails 4: check if a local variable exists and is true in a partial
You can check the local_assigns
hash, which includes the passed locals.
<section
id="view-dashboard"
class="<%= 'embedded' if local_assigns[:is_embedded] %>"
>
when rending the partial do this<%= render partial: "some_partial", locals: {is_embedded: true} %>
#_some_partial.html.erb
<%
#locals
is_embedded ||= false
%>
<section
id="view-dashboard"
class="<%= "embedded" if is_embedded %>">hhd</section>