它看起来像this。正在打印的信息来自下面的表格创建,我只是无法找到如何在不停止打印表格的情况下停止它。
这是相关的代码。
我对项目文件的索引视图
<div class="jumbotron jumbotron-fluid bg-primary">
<div class="container">
<h1 class="display-4">Hochschule München Student Projects</h1>
<p class="lead">This website holds all the student led projects along with information about each of them.</p>
</div>
</div>
<div class="jumbotron jumbotron-fluid bg-primary">
<div class="container">
<h1 class="display-4">Hochschule München Student Projects</h1>
<p class="lead">This website holds all the student led projects along with information about each of them.</p>
</div>
</div>
<h1>Listing projects</h1>
<br>
Filter by Professor
<%= collection_select(:project,:project_professor,Project.all.select(:project_professor).uniq,prompt: true) %>
<br>
<table border="1">
<tr>
<th><%= sortable "project_title","Project Title" %></th>
<th><%= sortable "project_professor","Professor" %></th>
<th><%= sortable "project_partner","Partner" %></th>
<th></th>
<th></th>
<th></th>
</tr>
<%= @projects.each do |project| %>
<tr>
<td><%= project.project_title %></td>
<td><%= project.project_professor%></td>
<td><%= project.project_partner%></td>
<td><%= link_to 'Show',project_path(project) %></td>
<td><%= link_to 'Edit',edit_project_path(project) %></td>
<td><%= link_to 'Destroy',project_path(project),method: :delete,data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
<br>
<%= link_to 'New project',new_project_path %>
这是控制器文件。
class ProjectsController < ApplicationController
helper_method :sort_column,:sort_direction
def index
@projects = Project.order(sort_column + " " + sort_direction); 0
end
def new
@project = Project.new
end
def create
@project = Project.new(project_params)
if @project.save
redirect_to @project
else
render 'new'
end
end
def edit
@project = Project.find(params[:id])
end
def update
@project = Project.find(params[:id])
if @project.update(project_params)
redirect_to @project
else
render 'edit'
end
end
def show
@project = Project.find(params[:id])
end
def destroy
@project = Project.find(params[:id])
@project.destroy
redirect_to projects_path
end
private
def project_params
params.require(:project).permit(:project_title,:project_semester,:project_partner,:project_format,:project_department,:project_description,:project_image,:project_link)
end
def sort_column
Project.column_names.include?(params[:sort]) ? params[:sort] : "project_title"
def sort_direction
%w[asc desc].include?(params[:direction]) ? params[:direction] : "asc"
end
end
感谢您的帮助!我已经有几天这个问题了,找不到错误。