i have an index.html.erb view, wich iterates the following:

<% @user_contents.each do |user_content| %>

<% end %>

My problem is that i need to render a form when the file is empty, for that content.

I've already set the @content this way:


def set_content
   @content = Content.find(params[:content_id])
end

That works fine, but I've been trying some conditionals like this:


<% if user_content.content.id == @content %>
  <% if user_content.file.blank? %>
   *Here i want to render my partial*
  <% else %>
   *Here i want to render a card*
  <% end %>
<% end %>

But this doesn't work.. I'll really appreciate your help.

Thanks a lot.

1 Answers

0
Ashok Damaniya On

avoid nested conditions, you can do it like this

<% if user_content.content.id.eql?(params[:id]) && user_content.file.present? %>
   *Here i want to render a card*
<% else %>
   *Here i want to render my partial*
<% end %>