草庐IT

function_entry

全部标签

ruby-on-rails - 在没有 :total_entries to improve a lengthy query 的情况下使用 will_paginate

我有一个will_paginate的当前实现,它使用paginate_by_sql方法来构建要分页的集合。我们有一个针对total_entries的自定义查询,它非常复杂并且给我们的数据库带来了很大的负载。因此,我们想从分页中完全删除total_entries。换句话说,我们只需要一个“下一个-上一个”按钮,而不是“上一个1[2]345下一个”的典型分页显示。但我们需要了解一些事情。我们是否显示上一个链接?这当然只会发生在当前选择中显示的记录之前存在的记录我们是否显示下一个链接?如果显示集合中的最后一条记录,则不会显示此内容来自docsAqueryforcountingrowswill

ruby - Delayed_job : how to use handle_asynchronously to work with a function?

函数是:defcreateuser(name,pass,time)putsname,pass,timeend我试试:handle_asynchronously:createuser("a","b","c")得到一个错误:语法错误,意外'(',期待keyword_end谢谢。===编辑===日本的用户数据库和北京的网络服务器。所以我用这种方式来创建用户。defcreateuser(name,pass,time)Net::HTTP.get(URI.parse("http://www.example.net/builduser.php?hao=#{name}&mi=#{pass}&da=#{

ruby - ruby 中#entries 和#to_a 的区别

#entries之间的基本区别是什么?和#to_aEnumerable的方法ruby中的模块。两者似乎在Hash上返回相同的结果>>hash={"name"=>"foo","age"=>"23"}=>{"name"=>"foo","age"=>"23"}>>hash.to_a=>[["name","foo"],["age",23]]>>hash.entries=>[["name","foo"],["age",23]] 最佳答案 这是区别(查看#=>之后的输出):h={}h.method(:entries)#=>#h.method(:

ruby - 使用 ruby​​ 应用程序时出现 remove_entry_secure 错误

我正在尝试使用docsplit将PDF文件拆分为图像。但看来我的ruby​​安装有问题。我每次都会收到以下错误:/usr/lib/ruby/1.8/fileutils.rb:694:in`remove_entry_secure':parentdirectoryisworldwritable这是完整的命令行输出:$docsplitimagespdf-test.pdf/usr/lib/ruby/1.8/fileutils.rb:694:in`remove_entry_secure':parentdirectoryisworldwritable,FileUtils#remove_entry_

jquery - 在 rails 中通过 remote_function 中的表单生成器?

我有选择框,在更改时我需要获取值,并通过远程函数从数据库中获取一些字段名称,然后根据从选择框中选择的选项进一步生成这些字段。问题是字段在f.form_for中,所以正在使用具有选择框的formbuilderf。所以当我在Controller中通过ajax呈现部分时,我收到错误消息,因为我没有引用到本地表单生成器f。有谁知道我如何或是否可以获取对表单生成器的引用,或者是否可以在远程函数调用中传递它,然后在部分中传递给我的本地人?非常感谢,任何帮助都会很棒,因为很长一段时间以来一直停留在这个问题上!干杯rake 最佳答案 我遇到了同样的

Ruby module_function,调用模块的私有(private)方法,在模块的类方法样式中调用显示错误

test_module.rbmoduleMyModuledefmodule_func_aputs"module_func_ainvoked"private_bendmodule_function:module_func_aprivatedefprivate_bputs"private_binvoked"endendclassMyClassincludeMyModuledeftest_modulemodule_func_aendend从类中调用模块函数c=MyClass.newc.test_module输出1:$rubytest_module.rbmodule_func_ainvoked

ruby-on-rails - Rails 3.1 与 PostgreSQL : GROUP BY must be used in an aggregate function

我正在尝试加载按user_id分组并按created_at排序的最新10个艺术。这适用于SqlLite和MySQL,但在我的新PostgreSQL数据库上出错。Art.all(:order=>"created_atdesc",:limit=>10,:group=>"user_id")ActiveRecord错误:ArtLoad(18.4ms)SELECT"arts".*FROM"arts"GROUPBYuser_idORDERBYcreated_atdescLIMIT10ActiveRecord::StatementInvalid:PGError:ERROR:column"arts.i

ruby-on-rails - 无法写入未知属性 `scrapbook_entry_id'

正在尝试将数据添加到scrapbook_entries的连接表中,其中has_one:scrapbook和has_one:recipe。:recipe和:scrapbook已经存在。我正在尝试添加它们以将它们与scrapbook_entries表链接起来。form_for添加到scrapbook_entries表:scrapbook_entries_path(params[:id]))do|f|%>@recipe.id%>剪贴簿_条目_Controller:defcreate@recipe=Recipe.find(params[:scrapbook_entry][:recipe_id]

ruby-on-rails - rails 3 : Call functions inside controllers

如果我想在Controller内部调用函数,我应该把它们放在哪里? 最佳答案 如果您希望它在Controller本地,那么您需要做的就是将它添加到您希望使用的Controller。privatedefmyfunctionfunctioncode.....end对于所有Controller,您可以将它放在应用程序Controller中,因为所有Controller都是子类。应用程序Controllerprotecteddefmyfunctionfunctioncode.....end如果你想访问你的View,那么你可以创建一个助手应用

ruby - 在没有 rvm 或 rbenv 的情况下编译 Ruby 2.0 错误, `readline.c:1886:26: error: ' Function' undeclared (first use in this function)`

我想安装gitlab,不推荐使用任何ruby版本管理器。但是这是我的操作系统Linuxdqa-dev3.13.0-24-generic#46-UbuntuSMPThuApr1019:08:14UTC2014i686i686i686GNU/Linuxlinkingshared-objectpsych.soinstallingdefaultpsychlibrariesmake[2]:Leavingdirectory`/home/poc/ruby-2.0.0-p451/ext/psych'make[2]:Enteringdirectory`/home/poc/ruby-2.0.0-p451/