Tag: nomethoderror

#Grease :: Adapter(Less :: Rails :: ImportProcessor)的未定义方法`new’

我在Gemfile中更新了一个gem,并在运行“bundle”命令后开始面对Grease :: Adapter错误。 问题似乎与我的应用程序的CSS。 错误如下: NoMethodError: undefined method `new’ for # 我正在使用rails版本“4.1.8”。 任何人都可以帮我解决这个问题吗?

带有HTTP get的Ruby NoMethodError(未定义的方法`set_body_internal’)

我是Ruby编程的新手。 我试图获得带有HTTP GET请求的谷歌XRDS,但是运行到NoMethodError(未定义的方法`set_body_internal’)错误。 以下是我的代码。 任何帮助深表感谢。 require “net/https” require “uri” class OpenidController < ApplicationController def getOpenIdXRD print "Hello…\n" uri = URI.parse("https://gmail.com/.well-known/host-meta") print "Hello…1\n" # Shortcut #response1 = Net::HTTP.get_response(uri) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE print "Hello…2\n" File response1 = http.request(request) print "Hello…3\n" response1.body response1.status # Will print response.body # Net::HTTP.get_print(uri) end end […]

Ruby:私有方法调用3:Fixnum

我试图了解这个简单函数的细微差别,但我不确定我需要做些什么来修复这个NoMethodError。 如何将“拆分”公开而不是私有? 这会解决问题吗? 这是我的代码: DATA = [3, 4, 5, 6, 7, 8] DATA.each do |line| vals = line.split print vals[0] + vals[1], ” ” end 这是我在IRB中运行时收到的错误消息: NoMethodError: private method `split’ called for 3:Fixnum

尝试访问包含模块中定义的方法时出现NoMethodError

我正试图从我的一个规范助手中的模块中访问一个方法 我将模块包含在测试助手中 module Support class RestHelper include Rest::Rest def create_rest_client_for_ifa # Call method from module create_rest_client(uname, pword) end end end 但是当我运行我的规范时,我不断收到NoMethodError: Failure/Error: @rest_client = Support::RestHelper.create_rest_client_for_ifa NoMethodError: undefined method `create_rest_client’ for Support::RestHelper:Class 这是我的模块代码: module Rest module Rest . . def create_rest_client(uname, pword) # code end . . end end 当我在rails控制台中测试它时似乎工作正常 $ RAILS_ENV=test rails c irb> include […]

Rails 3.2.3命名空间控制器被具有相同名称的全局控制器覆盖

首先加载全局应用程序控制器时,在该名称空间中加载页面时,不会加载命名空间的应用程序控制器。 应用程序控制器如下所示: class ApplicationController < ActionController::Base protect_from_forgery end 命名空间的应用程序控制器如下所示: class Admin::ApplicationController < ApplicationController def authenticate_admin! if current_admin.nil? redirect_to new_admin_session_url end end private def current_admin @current_admin ||= Admin.find(session[:admin_id]) if session[:admin_id] end helper_method :current_admin end 当我们使用before_filter“authenticate_admin!”时 像这样: class Admin::AssetsController < Admin::ApplicationController before_filter :authenticate_admin! end 抛出“Admin :: AssetsController #new中的NoMethodError”。 仅当我们在命名空间路由之前命中全局路由时才会发生这种情况。 如果服务器重新启动并且加载了命名空间路由,则一切正常。

Ruby中的`try`和`&.`(安全导航操作符)有什么区别?

这是我的代码: class Order < Grape::Entity expose :id { |order, options| order.id.obfuscate } expose :time_left_to_review do |order, options| byebug order&.time_left_to_review # ERROR end expose :created_at { |order, options| order.last_transition.created_at } end # NoMethodError Exception: undefined method `time_left_to_review' for # 我想&. 是.try的捷径,但我想我错了。 可能有人指出我正确的方向,我错过了什么? 我觉得这不是ruby相关的。 葡萄可能吗? 虽然我不明白它是怎么回事。

MacRuby,使用续集时出错

我刚刚使用命令sudo macgem install sequel安装了Sequel 。 它告诉我sequel-3.18.0已成功安装。 当我启动xcode并启动新的MacRuby应用程序时,它会为unit testing设置目标。 我用以下两行修改了stub_test.rb : require “rubygems” require “sequel” 尝试运行unit testing时,出现以下错误: /Users/…/macRuby Test/Tests/run_suite.rb:1:in `’: super: no superclass method `require’ for Sequel:Class (NoMethodError) 没有两个require语句,测试运行正常。 我试图谷歌这个,并在macruby.org上找到以下票 : 机票#930 SIGABRT在MacRuby 0.7中使用Sequel + SQLite3-Ruby gem […]在Sequel修补内核#require问题后,我可以加载Sequel和SQLite3,没有任何问题。 […]必需的库是Sequel(Patched for Kernel.require,而不是Sequel#self.require中的super)和SQLite3-Ruby。 […] 我在其他地方找不到关于这个补丁的任何信息,不过…… 有没有已知的问题? 这个错误消息意味着什么,以及我如何让它工作?

为什么我在生产中遇到“未定义的方法’paginate’”错误?

在生产服务器上使用will_paginate时出现此错误: I, [2013-10-24T20:17:40.386696 #18564] INFO — : Started GET “/meals” for 190.273.432.55 at 2013-10-24 20:17:40 +0000 I, [2013-10-24T20:17:40.388972 #18564] INFO — : Processing by MealsController#index as HTML I, [2013-10-24T20:17:40.395022 #18564] INFO — : Completed 500 Internal Server Error in 6ms F, [2013-10-24T20:17:40.396720 #18564] FATAL — : NoMethodError (undefined method `paginate’ for #): app/controllers/meals_controller.rb:5:in `index’ 这是我在控制器中使用它的方式: […]

未定义的方法(NoMethodError)ruby

我一直收到以下错误消息: text.rb:2:in `’: undefined method `choices’ for main:Object (NoMethodError) 但我似乎无法理解为什么我的方法是“未定义的”: puts “Select [1] [2] [3] or [q] to quit”; users_choice = gets.chomp choices(users_choice) def choices (choice) while choice != ‘q’ case choice when ‘1’ puts “you chose one!” when ‘2’ puts “you chose two!” when ‘3’ puts “you chose three!” end end end