Weird code appearing when I loop over model instances in Rails

Posted by Tom Maxwell on Stack Overflow See other posts from Stack Overflow or by Tom Maxwell
Published on 2013-10-28T03:47:05Z Indexed on 2013/10/28 3:53 UTC
Read the original article Hit count: 201

Filed under:
|

In my Rails app I'm trying to loop over the Submission instances inside my Folder instances with Rails templating code. It works. However, it's also returning each instance in code which doesn't seem to be JSON. It's what's returned when you look up an instance in the Rails console. Here's an example:

#<Submission id: 112, title: nil, content: nil, created_at: "2013-10-10 23:29:39", updated_at: "2013-10-10 23:29:39", user_id: 1, folder_id: 1, parent_id: nil>

Here's what the code looks like for the loop:

<%= @folder.submissions.each do |x| %>
      <% if x.title != nil %>
        <div id="<%= x.id %>" class="submission-textual">
          <h1><%= x.title %></h1>
        </div>
      <% else %>
      <% end %>
    <% end %>

I checked my Folder and Submissions controllers but am not sure what this is. Why are these strings being rendered whenever I try and render an instance in my view? I'm still new to Ruby so that explains why I haven't seen this.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby