草庐IT

CATALOG_NUMBER

全部标签

ruby - Sinatra 服务器无法启动 - "wrong number of arguments"

我想尝试Sinatra,因为我听说它对网络开发新手来说比Rails更好......而且总的来说,我更喜欢简约。为此,我使用的是ruby​​2和gem安装获得的任何版本的sinatra。到目前为止我所做的只是基本的require'sinatra'get'/'do'Hello,World!'end尝试使用ruby​​basics.rb运行服务器,它向我抛出这个:/home/ch35hir3/.rvm/gems/ruby-2.0.0-p247/gems/thin-2.0.0.pre/lib/thin/server.rb:108:in`initialize':wrongnumberofargu

ruby-on-rails - 无法在 Rails 5.0 的 ApplicationHelper 方法中使用 "number_with_precision"

我在RailsView中使用“number_with_precision”方法,它在那里工作正常,例如:在RailsView中:(工作正常)2)%>但是当我尝试在ApplicationHelper的方法中做同样的事情时,它会给我以下错误:undefinedmethod`number_with_precision'rails这是我尝试过的:在RailsApplicationHelper中:(给出错误)moduleApplicationHelperdefemployer_overall_rating(overall_rating)@overall_rating=number_with_pr

ruby-on-rails - FactoryGirl 问题 - `factory' : wrong number of arguments (0 for 1) (ArgumentError)

我正在学习RubyonRails教程,我已经接近尾声了,但是FactoryGirl并没有让我轻松完成。我无法运行任何需要工厂的规范文件。require'spec_helper'require'factory_girl_rails'describeUserdobefore(:each)do@attr={:name=>"ExampleUser",:email=>"user@example.com",:password=>"foobar",:password_confirmation=>"foobar"}endit"shouldcreateanewinstancegivenvalidattr

ruby - 液体错误 : wrong number of arguments

我正在尝试一个简单的Jekyll插件:classMonthlyArchives当我尝试按如下方式在页面中运行它时:{%monthly_archives1%}我收到Liquid错误:参数数量错误(2代表0)。有什么想法吗? 最佳答案 我还没有机会用Liquid构建一些东西,但是Jekyllwikipageaboutbuildingyourownplugins在注册之前让整个类(class)都被模块包围moduleJekyll...yourcode...endLiquid::Template.register_tag('monthly_

ruby-on-rails - rails : How to Implement Number of Post Views?

有什么问题?我正在创建一个通用博客,并致力于创建基本功能。问题是View(有多少人看过特定帖子)未正确显示。技术现状:。此时我有两个Controller/模型:发布和评论。我将为您提供我的架构,以帮助您更好地了解情况。create_table"comments",:force=>truedo|t|t.string"name"t.text"body"t.integer"like"t.integer"hate"t.integer"post_id"t.datetime"created_at",:null=>falset.datetime"updated_at",:null=>falseend

ruby - 尝试使用 SecureRandom.random_number ruby​​ 2.0.0 的包含范围

我正在使用securerandom,问题是它包含数字“0”,如0..56,和0..46而不是1..56,以及1..46(彩票不包含数字0)。0可以在下面的第二个百万数字输出中看到。我以为我找到了一种方法来排除下面的0(char1,char2),但我失败了。当我使用包含范围的rand(1..56)时,它工作得很好(但一些帖子建议远离rand())。但是,当我尝试在securerandom上使用包含char1和char2的包含范围时,它不起作用。Error:[nil@nillottery]$./mega_millions.rb/dev/null/.rvm/rubies/ruby-2.0.0

ruby-on-rails - 目录 : Wrong Number of Arguments

我试图在我的Rails3代码中调用一个方法,但得到:Failure/Error:integration_sign_inwrong_userArgumentError:wrongnumberofarguments(0for1)这是调用代码(在RSpec助手中):before(:each)dowrong_user=Factory(:user,:email=>"test@test.com",:password=>"hellohello",:password_confirmation=>"hellohello")integration_sign_inwrong_userend所以它显然是在传递

ruby - 鹿石 : ArgumentError: wrong number of arguments with sandboxed code

我在调用具有多个参数的方法时遇到Shikashi问题:classMyTestdefself.thinkmessageenddefself.sayperson,messageendendincludeShikashiprivileges=Privileges.newprivileges.allow_const_read"MyTest"privileges.object(MyTest).allow_allprivileges.instances_of(MyTest).allow_allSandbox.new.run(privileges,"MyTest.think('you')")Sand

ruby 邮件程序 : Wrong number of arguments

我正在构建我的邮件程序,但我一直遇到:wrongnumberofarguments(0for1)说我疯了,但我觉得我定义的一切都是正确的:Controller(为简洁起见被截断):defcreate@cms484=Cms484.new(cms484_params)respond_todo|format|if@cms484.saveSendLink.message(@cms484).deliver_laterformat.html{redirect_tocms484s_path,notice:'Cms484wassuccessfullycreated.'}format.json{rend

ruby-on-rails - to_json 方法中的 Rails "wrong number of arguments (1 for 0)"

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Overrideto_jsoninRails2.3.5lib/responses.rbmoduleResponsesclassResponsedefto_jsonJSON.pretty_generate(self)endendclassErrorResponse这由Controller使用:response=Responses::DataResponse.newresponse.data=someDatarender:json=>response现在我在lib/responses.rb:3:into_json