Table in partial view not rendering

upperlacon

I am trying to display a table of jobs for a client sectioned by month year. The partial views evaluate and using binding.pry on each I can see that the correct values are there. The _month_section.html.erb date does not show, nor does the table in _jobs.html.erb

clients_controller.rb

def show
  if id = params[:id]
    if @client = current_user.clients.find_by_id(id.to_i) 
      if @client.jobs.count > 0
       @jobs_by_month = @client.jobs.group_by{|j| j.created_at.strftime('%B %Y')}
      end
    else
      redirect_to dashboard_path
    end      
  end
end

show.html.erb

<% if @client.jobs.count > 0 %>
  <div class="row">
    <div class="col-lg-12 col-md-12">
      <div class="panel panel-white">
        <div class="panel-heading">
          <h4 class="panel-title">Jobs</h4>
            <div class="panel-body">
                <%= render 'month_section' %>
            </div>
        </div>
      </div>
    </div>
  </div>
<% end -%>

_month_section.html.erb

<div class="month_section" >
    <% @jobs_by_month.each do |date, jobs| %>
         <div>
           <h3><%= date %></h3>
           <%= render partial: 'jobs', :locals => {:jobs => jobs } %>
         </div>
    <% end %>
</div>

_jobs.html.erb

<div class="jobs">
  <div class="row">
    <div class="col-lg-12">
            <div class="table-responsive">
              <table class="table table-hover">
                    <thead>
                    <tr>
                      <th>Date</th>
                      <th>Start Time</th>
                      <th>End Time</th>
                    </tr>
                  </thead>
                      <tbody>
                         <% jobs.each do |job| %>
                             <tr>
                              <td><%= job.date%></td>
                              <td><%= job.start_time %></td>
                              <td><%= job.end_time %></td>
                            </tr>
                         <% end %>
                        </tbody>
                    </table>
            </div>
        </div>
    </div>
</div>
upperlacon

Turns out issue was due to a rogue non-terminated div tag on show.html.erb outside of the snippet I posted.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Scripts not rendering in partial view

From Dev

Rendering a partial view with jquery

From Dev

MVC Partial View not rendering

From Dev

Partial View Not Rendering Inside View

From Dev

Html.Partial not rendering partial view

From Dev

Rendering a partial View with Ajax Unobtrusive

From Dev

Rendering a partial with ajax - missing view

From Dev

UI issues for partial view rendering

From Dev

Dynamically rendering partial view on iPad

From Dev

Error when rendering a Partial View

From Dev

Rendering a partial view in MVC with Javascript

From Dev

Rendering a partial View with Ajax Unobtrusive

From Dev

Rendering a View in another View (Not a partial view)

From Dev

MVC Partial View is not rendering correctly in main View

From Dev

MVC Partial View is not rendering correctly in main View

From Dev

Populating table in a partial view

From Dev

Populating table in a partial view

From Dev

Umbraco 7 Partial View Macro Rendering

From Dev

Partial view not rendering because TempData is null

From Dev

Backbone partial view not rendering the latest model

From Dev

Error when rendering shared partial view as string

From Dev

MVC Partial View not rendering from an EditorTemplates

From Dev

Why isn't my table partial rendering?

From Dev

(Nancy) Razor View Engine partial view rendering full HTML

From Dev

View rendering as plain text when action called from partial view

From Dev

Table View UIImage rendering issue

From Dev

Rendering same partial view multiple times - Only the last partial view is rendered

From Dev

Rendering Devise edit form as partial on another view with user data

From Dev

Rendering partial view on button click in ASP.NET MVC

Related Related

HotTag

Archive