草庐IT

The Digital Journey of Microsoft AI & IoT Insider Lab and Partners

全部标签

ruby-on-rails - RoR && "coming soon"页面

我正在寻找一种简单的方法来为我在RubyonRails上的项目实现简单的“即将推出”(预启动)页面。用户应该能够留下电子邮件以便在项目启动时收到通知。有没有这样的插件\gem?或者我应该自己做... 最佳答案 LaunchingSoon是一个Rails插件。它还集成了MailChimp或Campaignmonitor. 关于ruby-on-rails-RoR&&"comingsoon"页面,我们在StackOverflow上找到一个类似的问题: https:/

ruby - rails 3.2.2(或 3.2.1)+ Postgresql 9.1.3 + Ubuntu 11.10 连接错误

我正在使用PostgreSQL9.1.3(x86_64-pc-linux-gnu上的PostgreSQL9.1.3,由gcc-4.6.real(Ubuntu/Linaro4.6.1-9ubuntu3)4.6.1,64位编译)和在ubuntu11.10上运行3.2.2或3.2.1。现在,我可以使用以下命令连接PostgreSQLsupostgres输入密码我可以看到postgres=#我将以下详细信息放在我的config/database.yml中并执行“railsdb”,它工作正常。开发:adapter:postgresqlencoding:utf8reconnect:falsedat

ruby - 优雅的链式 'or' 用于测试 Ruby 中的相同变量

怎样说才是明智的呢?if@thing=="01"or"02"or"03"or"04"or"05"(数字包含在数据类型字符串的列中。) 最佳答案 制作数组并使用.include?if["01","02","03","04","05"].include?(@thing)如果值真的都是连续的,你可以使用像(1..5).include?这样的范围对于字符串,你可以使用:if("01".."05").include?(@thing) 关于ruby-优雅的链式'or'用于测试Ruby中的相同变量,我

ruby-on-rails - ApplicationController :Class 的未定义方法 `caches_action'

我正在尝试升级到Rails4beta1,但遇到了一些问题。简而言之,这就是我的应用程序Controller的样子。classApplicationControllercaches_action在Rails4中移到了它自己的gem中,因此包含gem应该可以解决问题。gem"actionpack-action_caching",github:"rails/actionpack-action_caching"但是当我运行我的请求规范或在浏览器中访问该应用程序时,我收到此错误。app/controllers/application_controller.rb:3:in`':undefinedm

ruby - 什么是 "Class.new"?

我不明白下面这段代码中的Sheep=Class.new部分。moduleFenceSheep=Class.newdodefspeak"Bah."endendenddefcall_sheepFence::Sheep.new.speakend它到底在做什么? 最佳答案 根据文档,Class.newCreatesanewanonymous(unnamed)classwiththegivensuperclass(orObjectifnoparameterisgiven).此外,Youcangiveaclassanamebyassigning

ruby-on-rails - 如何将 'Fixnum' 转换为 Rails 3.1.3 中的日期?

我正在尝试将此输出显示为日期:1296524384但是当我在上面调用.to_date时,出现了这个错误:undefinedmethod`to_date'for1296524384:Fixnum 最佳答案 你可以这样做:the_time=Time.at(1296524384)这给你:2011-01-3120:39:44-0500顺便说一句,1296524384指的是UNIX或纪元时间。它测量自1970年1月1日以来经过的秒数。为了更好地格式化它,您可以使用Ruby的strftime方法。the_time=Time.at(1296524

ruby - 在 Ruby + Chef 中检查现有目录失败

这是我在ChefRecipe中的一blockRuby:#ifdatadirdoesn'texist,moveoverthedefaultoneif!File.exist?("/vol/postgres/data")execute"mv/var/lib/postgresql/9.1/main/vol/postgres/data"end结果是:Executingmv/var/lib/postgresql/9.1/main/vol/postgres/datamv:inter-devicemovefailed:`/var/lib/postgresql/9.1/main'to`/vol/post

ruby-on-rails - 无法捆绑安装 'open-uri'

关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。关于您编写​​的代码问题的问题必须在问题本身中描述具体问题—并且包括有效代码以重现它。参见SSCCE.org寻求指导。关闭8年前。Improvethisquestion我是Rails的新手。我正在制作一个网络应用程序,我在其中使用nokogiri搜索不同的网站以从中提取文本。所以在Gemfile中,我写了require'nokogiri'和'open-uri',但是当我捆绑安装时我得到这个错误:Couldnotfindgem'open-uri(>=0)ruby'inthegemsavailableon

ruby-on-rails - rails:为#<StateMachine::Machine:0xba3014ec> 调用了 protected 方法 `around_validation'

我正在尝试实现state_machinegem,在我的rails项目中,我安装了gem,然后我将“state”列添加到我的account_entries模型中:defchangeadd_column:account_entries,:state,:stringend然后在我的account_entries模型中,我添加了状态机初始方法,如下所示:state_machine:state,:initial=>:submitteddoend然后在我看来我显示时间进入状态:account_entry.state但是当我尝试从我的应用程序创建一个account_entry时,我得到了这个错误:p

ruby-on-rails - 获取 ActionController::RoutingError(当尝试使用 AngularJS 将数据发布到 Rails 服务器时,没有路由匹配 [OPTIONS] "/users"

尝试从我的AngularJS端将数据发布到Rails服务器时出现问题。服务器错误:ActionController::RoutingError(Noroutematches[OPTIONS]"/users"):actionpack(4.1.9)lib/action_dispatch/middleware/debug_exceptions.rb:21:in`call'actionpack(4.1.9)lib/action_dispatch/middleware/show_exceptions.rb:30:in`call'railties(4.1.9)lib/rails/rack/logg