简体   繁体   English

NoMethodError(#的未定义方法“页面” <Broadcast:0x00000003fd9320> ):

[英]NoMethodError (undefined method `page' for #<Broadcast:0x00000003fd9320>):

I am a bit new to rails, and one of my task is migrating a rails 2.1 app to 3.2. 我对Rails有点陌生,我的任务之一是将Rails 2.1应用程序迁移到3.2。 Start steb by step, first 2.1 to 2.3 rails, and now to 3.2. 逐步开始排骨,首先从2.1到2.3滑轨,然后到3.2。

Can't use bundle or gem file but I have all the gems I need installed. 无法使用捆绑软件或gem文件,但我已安装了所有需要的gem。

My issue is now converting will paginate methods. 我的问题是现在将转换分页方法。

I had my requires in an /config/initializer/load.rb in this order 我按此顺序在/config/initializer/load.rb中有我的要求

require 'rails' require 'rails/all' require 'prototype-rails' require 'will_paginate' 需要'rails'需要'rails / all'需要'prototype-rails'需要'will_paginate'

The libs are loaded with success. 库已成功加载。

But when I try to use paginate in my source I get this error. 但是,当我尝试在源代码中使用分页时,会出现此错误。

NoMethodError (undefined method `page' for #<Broadcast:0x00000003fd9320>):
  app/controllers/broadcasts_controller.rb

my controller is has this code: 我的控制器具有以下代码:

@broadcasts = Broadcast.page(params[:page] || 1).select(select_clause).order( order_clause)

the broadcast model is something like 广播模型就像

class Broadcast < ActiveRecord::Base
  extend PhoneNumberFormatValidation
  ...
end

I try to put the "require will_paginate" just before my controller but it didn't work. 我尝试将“ require will_paginate”放在我的控制器之前,但是没有用。 If I run rails console 如果我运行Rails控制台

[user1@virtual-rh6x64 web]$ rails c
irb(main):001:0> require 'will_paginate'
=> false

I don't understand why can't find will paginate methods. 我不明白为什么找不到分页方法。 Does he work with ActiveRecord::Base? 他是否使用ActiveRecord :: Base?

my gems are: 我的宝石是:

*** LOCAL GEMS ***

actionmailer (3.2.11)
actionpack (3.2.11)
activemodel (3.2.11)
activerecord (3.2.11)
activerecord-oracle_enhanced-adapter (1.4.1)
activeresource (3.2.11)
activesupport (3.2.11)
arel (3.0.2)
bigdecimal (1.1.0)
builder (3.0.4)
bundler (1.2.3)
coderay (1.0.5)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.4.0)
dbi (0.4.5)
deprecated (2.0.1)
erubis (2.7.0)
execjs (1.3.2)
fastercsv (1.5.0)
hike (1.2.1)
i18n (0.6.1)
io-console (0.3)
journey (1.0.4)
jquery-rails (2.1.4)
json (1.7.7)
libv8 (3.11.8.13 x86_64-linux)
libxml-ruby (2.1.0)
mail (2.4.4)
method_source (0.8.2)
mime-types (1.19)
minitest (3.2.0)
multi_json (1.7.2)
pg (0.14.1)
polyglot (0.3.3)
prototype-rails (3.2.1)
pry (0.9.12)
puma (1.6.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.2)
rails (3.2.11)
railties (3.2.11)
rake (0.9.2.2)
rdoc (3.12)
ref (1.0.2)
ruby-oci8 (2.1.2)
ruby-plsql (0.5.0)
sass (3.2.5)
sass-rails (3.2.5)
slop (3.4.6)
sprockets (2.2.1)
therubyracer (0.11.4)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.12)
tzinfo (0.3.35)
uglifier (1.3.0)
will_paginate (3.0.2)

Try using 尝试使用

 require 'will_paginate/active_record'

To load specific childs you may need to track down what childs will_paginate loads in a normal setup through Bundler.. because in that way it doesn't require loading these childs 要加载特定的子级,您可能需要通过Bundler跟踪正常设置中哪些子级will_paginate加载。因为那样,就不需要加载这些子级

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ` <module:Types> &#39;:#的未定义方法`/&#39; <String:0x007fd44c8f5318> (NoMethodError)数据映射器 - `<module:Types>': undefined method `/' for #<String:0x007fd44c8f5318> (NoMethodError) Datamapper NoMethodError:未定义的方法“ liquidity_manager?” 对于# <Order:0x007fd9b7a4cf98> - NoMethodError: undefined method `liquidity_manager?' for #<Order:0x007fd9b7a4cf98> 未定义的方法`each&#39;for# <String:0x00000003a27a58> - undefined method `each' for #<String:0x00000003a27a58> lynda Rails Tut:NoMethodError:#的未定义方法“页面” - lynda Rails Tut: NoMethodError: undefined method `page' for #<Subject:0x Capistrano:NoMethodError:#的未定义方法`recv&#39; <IO:fd XX> - Capistrano : NoMethodError: undefined method `recv' for #<IO:fd XX> Rails 控制台:NoMethodError:未定义方法 `attributes_builder&#39; #<Array:0x007fd7af09f8b0> - Rails console: NoMethodError: undefined method `attributes_builder' for #<Array:0x007fd7af09f8b0> Devise :: RegistrationsController#中的NoMethodError为#创建未定义的方法`confirmation_sent_at =&#39; <User:0x007fd83f5ccb68> - NoMethodError in Devise::RegistrationsController#create undefined method `confirmation_sent_at=' for #<User:0x007fd83f5ccb68> 未定义的方法`each&#39;for“# <Complaigns::ActiveRecord_Relation:0x00000003cfb4c8> “:串 - undefined method `each' for “#<Complaigns::ActiveRecord_Relation:0x00000003cfb4c8>”:String 为#设计未定义的方法`users_url&#39; <Devise::RegistrationsController:0x00000003b299b0> - Devise undefined method `users_url' for #<Devise::RegistrationsController:0x00000003b299b0> #&lt;#的未定义方法`students_path&#39; <Class:0x00000003b7a860> :0x00000003b6d6d8&gt;是什么意思? 学生路径 - undefined method `students_path' for #<#<Class:0x00000003b7a860>:0x00000003b6d6d8> Did you mean? student_path
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM