What is the correct syntax for checking if locales have been defined and passed in partial?
For example, I do partial
<%= render partial: "data-map", locals: {lat: @model.lat, lon: @model.lon, zoom: 10} %>
And in a partial need to do something like
<%= map( options: { latitude: if lat.defined? ? lat : 0, longitude: if lon.defined? ? lon : 0, zoom: if zoom.defined? ? zoom : 50 } %>
I have problems with this.
I also saw the following in the API
<% if local_assigns.has_key? :headline %> Headline: <%= headline %> <% end %>
but I also have problems with this. Maybe I am not getting the syntax correctly.
Thanks for any pointers
source share