<% @course.sections.rank(:row_order).each do |section| %>
<br /><br />
<div class="section">
<h3>
<%= section.title %>
</h3>
我在部分中获得该行顺序的未定义列。这是我的部分模型...
class Section < ActiveRecord::Base
belongs_to :course
has_many :lessons
include RankedModel
ranks :row_order, :with_same => :course_id
end
这是我的移民。
class AlterSectionsAddRowOrder < ActiveRecord::Migration
def change
add_column :sections, :row_order, :integer
add_index :sections, :row_order
end
end
如果这有用,这是我收到的错误消息。
在2015-05-07 23:41:49 +0000,由CoursesController#show以HTML参数形式进行处理,开始针对10.0.2.2的GET“ / courses / 13”:{“ id” =>“ 13”}课程负载(0.5毫秒) SELECT“ courses”。*从“ courses”哪里“ courses ..” id“ = $ 1 LIMIT 1 [[” id“,” 13“]]用户负载(0.5ms)SELECT” users“。* FROM” users“哪里“ users”。“ id” = 2 ORDER BY“ users”。“ id” ASC LIMIT 1用户负载(0.5ms)选择“ users”。* FROM“ users” WHERE“ users”。“ id” = $ 1 ORDER BY“ users“。” id“ ASC LIMIT 1 [[” id“,2]]课程已存在(0.4ms)从“课程”内联接中选择1作为“课程”内的“入学”。“ id” =“入学”。 ”course_id“ WHERE”注册“。” user_id“ = $ 1 AND” courses“。” id“ = 13 LIMIT 1 [[”“ user_id”,2]]区域加载(1.0ms)选择“ sections .. *”在“ sections”中“ sections”。“ course_id” = $ 1 ORDER BY“ sections ..” row_order“ ASC [[”“ course_id”,13]] PG :: UndefinedColumn:错误:列sections.row_order不存在LINE 1:... ons“ WHERE“ sections ..” course_id“ = $ 1 ORDER BY” sections“ ... ^:选择” sections“。* FROM” sections“ WHERE” sections。“” course_id“ = $ 1 ORDER BY” sections“。” row_order“ ASC在布局/应用程序中呈现的courses / show.html.erb(57.0毫秒)在240毫秒内完成了500个内部服务器错误enrollments“。” user_id“ = $ 1 AND” courses“。” id“ = 13 LIMIT 1 [[” user_id“,2]]部分加载(1.0ms)选择” sections“。*从” sections“中选择” sections“。 “ course_id” = $ 1 ORDER BY“ sections”。“行顺序” ASC [[“” course_id“,13]] PG :: UndefinedColumn:错误:列section.row_order不存在LINE 1:...在” sections“所在的位置。“ course_id” = $ 1 ORDER BY“ sections” ... ^:选择“ sections”。*从“ sections” WHERE“ sections ..”“ course_id” = $ 1 ORDER BY“ sections”。“ row_order” ASC呈现的课程/节目布局/应用程序中的.html.erb(57.0毫秒)在240毫秒内完成了500个内部服务器错误enrollments“。” user_id“ = $ 1 AND” courses“。” id“ = 13 LIMIT 1 [[” user_id“,2]]部分加载(1.0ms)选择” sections“。*从” sections“中选择” sections“。 “ course_id” = $ 1 ORDER BY“ sections”。“行顺序” ASC [[“” course_id“,13]] PG :: UndefinedColumn:错误:列section.row_order不存在LINE 1:...在” sections“所在的位置。“ course_id” = $ 1 ORDER BY“ sections” ... ^:选择“ sections”。*从“ sections” WHERE“ sections ..”“ course_id” = $ 1 ORDER BY“ sections”。“ row_order” ASC呈现的课程/节目布局/应用程序中的.html.erb(57.0毫秒)在240毫秒内完成了500个内部服务器错误id“ = 13 LIMIT 1 [[” user_id“,2]]部分加载(1.0ms)选择” sections“。*从” sections“位置” sections。“” course_id“ = $ 1 ORDER BY” sections ..“ row_order” ASC [[“” course_id“,13]] PG :: UndefinedColumn:错误:列section.row_order不存在LINE 1:...在” WHERE“ sections ..” course_id“ = $ 1 ORDER BY” sections“ ... ^:选择“ sections”。*从“ sections”那里“ sections”。“ course_id” = $ 1 ORDER BY“ sections ..” row_order“ ASC在布局/应用程序中呈现的courses / show.html.erb(57.0ms)已完成500内部服务器错误(240毫秒)id“ = 13 LIMIT 1 [[” user_id“,2]]部分加载(1.0ms)选择” sections“。*从” sections“位置” sections。“” course_id“ = $ 1 ORDER BY” sections ..“ row_order” ASC [[“” course_id“,13]] PG :: UndefinedColumn:错误:列section.row_order不存在LINE 1:...在” WHERE“ sections ..” course_id“ = $ 1 ORDER BY” sections“ ... ^:选择“ sections”。*从“ sections”那里“ sections”。“ course_id” = $ 1 ORDER BY“ sections ..” row_order“ ASC在布局/应用程序中呈现的courses / show.html.erb(57.0ms)已完成500内部服务器错误(240毫秒)section“。” course_id“ = $ 1 ORDER BY” sections ..“ row_order” ASC [[“” course_id“,13]] PG :: UndefinedColumn:错误:列sections.row_order不存在第1行:...在哪里” “ sections”。“ course_id” = $ 1 ORDER BY“ sections” ... ^:选择“ sections”。*从“ sections” WHERE“ sections ..”“ course_id” = $ 1 ORDER BY“ sections”。“ row_order” ASC呈现布局/应用程序内的courses / show.html.erb(57.0毫秒)在240毫秒内完成了500个内部服务器错误section“。” course_id“ = $ 1 ORDER BY” sections ..“ row_order” ASC [[“” course_id“,13]] PG :: UndefinedColumn:错误:列sections.row_order不存在第1行:...在哪里” “ sections”。“ course_id” = $ 1 ORDER BY“ sections” ... ^:选择“ sections”。*从“ sections” WHERE“ sections ..”“ course_id” = $ 1 ORDER BY“ sections”。“ row_order” ASC呈现布局/应用程序内的courses / show.html.erb(57.0毫秒)在240毫秒内完成了500个内部服务器错误= $ 1 ORDER BY“ sections” ... ^:选择“ sections”。*从“ sections”哪里“ sections”。“ course_id” = $ 1 ORDER BY“ sections ..” row_order“ ASC渲染的课程/show.html.erb在版面/应用程序中(57.0毫秒),在240毫秒内完成500个内部服务器错误= $ 1 ORDER BY“ sections” ... ^:选择“ sections”。*从“ sections”哪里“ sections”。“ course_id” = $ 1 ORDER BY“ sections ..” row_order“ ASC渲染的课程/show.html.erb在版面/应用程序中(57.0毫秒),在240毫秒内完成500个内部服务器错误
ActionView :: Template :: Error(PG :: UndefinedColumn:错误:列sections.row_order不存在LINE 1:...在“ WHERE” sections ..“ course_id” = $ 1 ORDER BY“ sections ...... ^:从“ sections”中选择“ sections”。*在“ sections”中的“ sections”中。“ course_id” = $ 1 ORDER BY“ sections ..” row_order“ ASC):42:43:44:45:<%@ course.sections.rank(: row_order).each do | section |%> 46:
47:48:app / views / courses / show.html.erb:45:in'_app_views_courses_show_html_erb___522001594__582727588'
渲染的/home/vagrant/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb(2.0 ms)呈现的/home/vagrant/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.9毫秒)呈现的/home/vagrant/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/template_error .erb在救援/版式内(19.6ms)
在2015-05-07 23:41:51 +0000由CoursesController#show以HTML参数的形式开始针对10.0.2.2的GET“ / courses / 13”,HTML参数:{“ id” =>“ 13”}课程负载(0.5ms) SELECT“ courses”。*从“ courses”哪里“ courses ..” id“ = $ 1 LIMIT 1 [[” id“,” 13“]]用户负载(0.6ms)SELECT” users“。* FROM” users“哪里“ users”。“ id” = 2 ORDER BY“ users”。“ id” ASC LIMIT 1用户负载(0.5ms)选择“ users”。* FROM“ users” WHERE“ users”。“ id” = $ 1 ORDER BY“ users“。” id“ ASC LIMIT 1 [[” id“,2]]课程已存在(0.3ms)从” courses“内联接中选择1 as” enrollments“在” courses“上。” id“ =” enrollments“。 ”course_id“ WHERE”报名“。” user_id“ = $ 1 AND” courses“。” id“ = 13 LIMIT 1 [[” user_id“,2]]部分加载(0.7ms)选择” sections .. *“在” sections“中“ sections”。“ course_id” = $ 1 ORDER BY“ sections ..” row_order“ ASC [[”“ course_id”,13]] PG :: UndefinedColumn:错误:列sections.row_order不存在LINE 1:... ons“ WHERE“ sections ..” course_id“ = $ 1 ORDER BY” sections“ ... ^:选择” sections“。* FROM” sections“ WHERE” sections。“” course_id“ = $ 1 ORDER BY” sections“。” row_order“ ASC在布局/应用程序中呈现的courses / show.html.erb(51.8毫秒)在163毫秒内完成了500个内部服务器错误enrollments“。” user_id“ = $ 1 AND” courses“。” id“ = 13 LIMIT 1 [[” user_id“,2]]部分加载(0.7ms)选择” sections“。*从” sections“中选择” sections“。 “ course_id” = $ 1 ORDER BY“ sections”。“行顺序” ASC [[“” course_id“,13]] PG :: UndefinedColumn:错误:列section.row_order不存在LINE 1:...在” sections“所在的位置。“ course_id” = $ 1 ORDER BY“ sections” ... ^:选择“ sections”。*从“ sections” WHERE“ sections ..”“ course_id” = $ 1 ORDER BY“ sections”。“ row_order” ASC呈现的课程/节目布局/应用程序中的.html.erb(51.8毫秒)在163毫秒内完成了500个内部服务器错误enrollments“。” user_id“ = $ 1 AND” courses“。” id“ = 13 LIMIT 1 [[” user_id“,2]]部分加载(0.7ms)选择” sections“。*从” sections“中选择” sections“。 “ course_id” = $ 1 ORDER BY“ sections”。“行顺序” ASC [[“” course_id“,13]] PG :: UndefinedColumn:错误:列section.row_order不存在LINE 1:...在” sections“所在的位置。“ course_id” = $ 1 ORDER BY“ sections” ... ^:选择“ sections”。*从“ sections” WHERE“ sections ..”“ course_id” = $ 1 ORDER BY“ sections”。“ row_order” ASC呈现的课程/节目布局/应用程序中的.html.erb(51.8毫秒)在163毫秒内完成了500个内部服务器错误id“ = 13 LIMIT 1 [[” user_id“,2]]节加载(0.7ms)选择” sections .. *“在” sections“中,在” sections。“中。” course_id“ = $ 1 ORDER BY” sections ..“ row_order” ASC [[“” course_id“,13]] PG :: UndefinedColumn:错误:列section.row_order不存在LINE 1:...在” WHERE“ sections ..” course_id“ = $ 1 ORDER BY” sections“ ... ^:选择“ sections”。*从“ sections”那里“ sections”。“ course_id” = $ 1 ORDER BY“ sections ..” row_order“ ASC在布局/应用程序中呈现的courses / show.html.erb(51.8ms)已完成500内部服务器错误(163ms)id“ = 13 LIMIT 1 [[” user_id“,2]]节加载(0.7ms)选择” sections .. *“在” sections“中,在” sections。“中。” course_id“ = $ 1 ORDER BY” sections ..“ row_order” ASC [[“” course_id“,13]] PG :: UndefinedColumn:错误:列section.row_order不存在LINE 1:...在” WHERE“ sections ..” course_id“ = $ 1 ORDER BY” sections“ ... ^:选择“ sections”。*从“ sections”那里“ sections”。“ course_id” = $ 1 ORDER BY“ sections ..” row_order“ ASC在布局/应用程序中呈现的courses / show.html.erb(51.8ms)已完成500内部服务器错误(163ms)section“。” course_id“ = $ 1 ORDER BY” sections ..“ row_order” ASC [[“” course_id“,13]] PG :: UndefinedColumn:错误:列sections.row_order不存在LINE 1:...在”“ “ sections”。“ course_id” = $ 1 ORDER BY“ sections” ... ^:选择“ sections”。*从“ sections” WHERE“ sections ..”“ course_id” = $ 1 ORDER BY“ sections”。“ row_order” ASC呈现布局/应用程序中的courses / show.html.erb(51.8毫秒)在163毫秒内完成了500个内部服务器错误section“。” course_id“ = $ 1 ORDER BY” sections ..“ row_order” ASC [[“” course_id“,13]] PG :: UndefinedColumn:错误:列sections.row_order不存在LINE 1:...在”“ “ sections”。“ course_id” = $ 1 ORDER BY“ sections” ... ^:选择“ sections”。*从“ sections” WHERE“ sections ..”“ course_id” = $ 1 ORDER BY“ sections”。“ row_order” ASC呈现布局/应用程序中的courses / show.html.erb(51.8毫秒)在163毫秒内完成了500个内部服务器错误= $ 1 ORDER BY“ sections” ... ^:选择“ sections”。*从“ sections”哪里“ sections”。“ course_id” = $ 1 ORDER BY“ sections ..” row_order“ ASC渲染的课程/show.html.erb在版面/应用程序中(51.8ms)在163ms内完成500个内部服务器错误= $ 1 ORDER BY“ sections” ... ^:选择“ sections”。*从“ sections”哪里“ sections”。“ course_id” = $ 1 ORDER BY“ sections ..” row_order“ ASC渲染的课程/show.html.erb在版面/应用程序中(51.8ms)在163ms内完成500个内部服务器错误
ActionView :: Template :: Error(PG :: UndefinedColumn:错误:列sections.row_order不存在LINE 1:...在“ WHERE” sections ..“ course_id” = $ 1 ORDER BY“ sections ...... ^:从“ sections”中选择“ sections”。*在“ sections”中的“ sections”中。“ course_id” = $ 1 ORDER BY“ sections ..” row_order“ ASC):42:43:44:45:<%@ course.sections.rank(: row_order).each do | section |%> 46:
47:48:app / views / courses / show.html.erb:45:in'_app_views_courses_show_html_erb___522001594__582727588'
渲染的/home/vagrant/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb(3.6 ms)呈现的/home/vagrant/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.3毫秒)呈现的/home/vagrant/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/template_error .erb在救援/版式内(21.3ms)
我的直接猜测是您忘记了运行迁移,并且此列从未添加。您可以通过查看db / schema.rb文件来确认该列存在(并且已运行迁移)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句