刚刚升级了 rails 5
然后就遇到了这个问题:
undefined method `cast_type' for #<ActiveRecord::ConnectionAdapters::PostgreSQLColumn:0x000000048d37f0>
Extracted source (around line #35):
@users=User.same_group_with(current_user)
@plans=Plan.where(user_id: @users.ids).search_plans_for_selected_time($time).includes(:user).order(:created_at)
@[email protected](page: params[:page], per_page: 10, total_entries: @plans.count).to_a
else
@plans=Plan.search_plans_for_selected_time($time).includes(:user).order(:created_at)
@[email protected](page: params[:page], per_page: 10, total_entries: @plans.count).to_a
具体的错误提示:
Started GET "/plans" for 127.0.0.1 at 2016-04-19 16:21:44 +0800
Processing by PlansController#index as HTML
User Load (1.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 9], ["LIMIT", 1]]
(0.3ms) SELECT "users"."id" FROM "users" WHERE "users"."tag" IN (2, 0)
(0.4ms) SELECT COUNT(*) FROM "plans" WHERE "plans"."user_id" IN (1, 9) AND (created_at between '2016-04-15 16:00:00' and '2016-04-16 16:00:00')
Plan Load (0.5ms) SELECT "plans".* FROM "plans" WHERE "plans"."user_id" IN (1, 9) AND (created_at between '2016-04-15 16:00:00' and '2016-04-16 16:00:00') ORDER BY "plans"."created_at" ASC LIMIT $1 OFFSET $2 [["LIMIT", 10], ["OFFSET", 0]]
missed ids -> [] | hitted ids -> [9]
Completed 500 Internal Server Error in 30ms (ActiveRecord: 2.3ms)
NoMethodError (undefined method `cast_type' for #<ActiveRecord::ConnectionAdapters::PostgreSQLColumn:0x000000048d37f0>):
app/controllers/plans_controller.rb:35:in `index'
Rendered /home/moshenglong/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.beta3/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (3.3ms)
Rendered /home/moshenglong/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.beta3/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.7ms)
Rendered /home/moshenglong/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.beta3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (0.6ms)
Rendered /home/moshenglong/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.beta3/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (19.4ms)
DEPRECATION WARNING: Accessing mime types via constants is deprecated. Please change `Mime::HTML` to `Mime[:html]`. (called from const_missing at /home/moshenglong/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.beta3/lib/action_dispatch/http/mime_type.rb:52)
Rendered /home/moshenglong/.rvm/gems/ruby-2.3.0/gems/web-console-2.3.0/lib/web_console/templates/_markup.html.erb (0.7ms)
Rendered /home/moshenglong/.rvm/gems/ruby-2.3.0/gems/web-console-2.3.0/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (0.5ms)
Rendered /home/moshenglong/.rvm/gems/ruby-2.3.0/gems/web-console-2.3.0/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.3ms)
Rendered /home/moshenglong/.rvm/gems/ruby-2.3.0/gems/web-console-2.3.0/lib/web_console/templates/style.css.erb within layouts/inlined_string (0.6ms)
DEPRECATION WARNING: Accessing mime types via constants is deprecated. Please change `Mime::WEB_CONSOLE_V2` to `Mime[:web_console_v2]`. (called from const_missing at /home/moshenglong/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.beta3/lib/action_dispatch/http/mime_type.rb:52)
Rendered /home/moshenglong/.rvm/gems/ruby-2.3.0/gems/web-console-2.3.0/lib/web_console/templates/console.js.erb within layouts/javascript (18.1ms)
Rendered /home/moshenglong/.rvm/gems/ruby-2.3.0/gems/web-console-2.3.0/lib/web_console/templates/main.js.erb within layouts/javascript (0.2ms)
Rendered /home/moshenglong/.rvm/gems/ruby-2.3.0/gems/web-console-2.3.0/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.4ms)
Rendered /home/moshenglong/.rvm/gems/ruby-2.3.0/gems/web-console-2.3.0/lib/web_console/templates/index.html.erb (34.0ms)
然后我发现只要删除了 tmp 文件夹里的cache
文件夹,再刷新一下页面就好了
但是下次再需要用到缓存的时候,就会继续出现undefined method
cast_type' for`这个问题..
有没有遇到过这问题的同志呢?你们怎么解决的