0

So I'm passing down locals to a partial via PublicActivity and try to render the partial on the users/show.html.erb file, like so:

<% @activities.each do |act| %>
  <% render partial: "posts/#{act.trackable.check_type}", 
  locals: { tweet: tweet.trackable }%>
<% end %>

But this results into nothing. I don't see the partial at all. It's not visible. All data that is passed down is not nil, double confirmed via byebug and rails console.

Any ideas what could cause the invisibility of the partial?

Prometheus
  • 799
  • 8
  • 28
  • 3
    Your `<% render partial` should be `<%= render partial` (with the equals sign), for it to render out to the browser. – Unixmonkey Mar 13 '19 at 19:52
  • How did i miss that. I literally looked for at least 1 hour at my code i didn't saw that. – Prometheus Mar 13 '19 at 20:55
  • Your recent edit made the whole question meaningless. Please edit to improve - not to vandalise. The attempt to delete a decent and answered question is not tolerated at StackOverflow. – Yunnosch Mar 13 '19 at 21:44

1 Answers1

4

<% %> Executes the ruby code, but doesn't print it.

<%= %> Prints the result into the erb file.

So, the code should be:

<%= render partial: "posts/#{act.trackable.check_type}", 
    locals: { tweet: tweet.trackable }%>

More:
<%# %> : is for comment in erb

Ahmed Kamal
  • 561
  • 6
  • 17