草庐IT

current_tenant

全部标签

ruby-on-rails - Ruby on Rails : if current page? 是主页,不显示表单

我不想显示表单,但前提是当前页面不是主页这是我目前所拥有的...我有我的路线设置:root'projects#index'我的看法:'projects',:action=>'index'))%>showsomestuff如果url是localhost:3000/projects,则不会显示但是它显示了它的localhost:3000所以我需要以某种方式确保它不会显示主页。另外,我有主页的搜索参数,但我仍然不想显示它是否像localhost:3000/projects?search=blahblahblah 最佳答案 使用root_p

ruby-on-rails - 运行 Heckle 时出错? `current_code' : undefined method `translate' for Ruby2Ruby

我正在尝试运行Heckle,但一直出现错误:>specspec/controllers/my_controller_spec.rb--heckleMyController!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!exception=hasathickskin.There'snothingtoheckle.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!(Runsthroughseveralmu

ruby-on-rails - after_save 回调将 updated_by 列设置为 current_user

我想使用after_save回调将updated_by列设置为current_user。但是current_user在模型中不可用。我应该怎么做? 最佳答案 需要在controller中处理。首先在模型上执行保存,然后如果成功则更新记录字段。例子classMyController另一种选择(我更喜欢这个)是在您的模型中创建一个自定义方法来包装逻辑。例如classRecord 关于ruby-on-rails-after_save回调将updated_by列设置为current_user,我

ruby-on-rails - Rails 3 上的 404 err 部署到 AWS...很好,除了 EB 不复制/ondeck 到/current

当我部署Rails应用程序时,我遇到了一些导致nginx1.2.3404错误的错误。在部署期间,EB说:“错误:某些实例未响应命令。未从[i-a054e9de]收到响应。”我可以登录到我的EC2并在var/app中“mvondecktocurrent”然后“touchcurrent/tmp/restart.txt”然后应用程序将正确部署并正常工作。它具有所有依赖项并正确连接到RDS数据库。问题是:我如何让aws服务器(elasticbeanstalk)进行最后的部署步骤,将ondeck复制到当前?我的配置文件中是否遗漏了什么?是否有我不小心更改了EB配置中的设置?顺便说一句,一切都很好

ruby - “运行失败跳转到方法定义”错误 : undefined method `current_line' for TextMate:Module

更新:我想通了。Ctrl-F仅在未选择我正在搜索的方法时有效。游标只需要在方法名中。我刚升级到TextMate2。当我选择一个方法并使用Ctrl+F转到它的定义时,我得到:>FailurerunningJumptoMethodDefinition这是痕迹:/Users/ilikepie/Library/ApplicationSupport/TextMate/Managed/Bundles/RubyonRails.tmbundle/Support/lib/rails/text_mate.rb:54:in`method_missing':undefinedmethod`current_li

ruby-on-rails - Ruby 为什么类实例变量是线程安全的

根据this回答是,但是张贴者说JRuby的工作方式不同所以我很困惑?我正在使用类实例变量实现Multi-Tenancy解决方案,因此无论我使用什么Ruby实现或Web服务器,我都需要确保数据不会泄露。这是我的代码:classTenant我需要做什么来确保无论发生什么(更改Ruby实现、更改Web服务器、新的Ruby线程功能等)我的代码都是线程安全的? 最佳答案 由于tenancy属性的范围是一个请求,我建议您将其保留在当前线程的范围内。由于一个请求是在单个线程上处理的,并且一个线程一次处理一个请求-只要您始终在请求开始时设置租期就

ruby-on-rails - 事件管理员 :select drop-down defaults to current value in development but defaults to blank in production

我有以下ActiveAdmin表单:formdo|f|f.inputs"TimesheetDetails"dof.input:jobs_assigned_worker,:label=>"Worker",as::select,collection:Worker.allf.input:worked_time_hours,:label=>"WorkedTime(Hours)"f.input:worked_time_mins,:label=>"WorkedTime(Minutes)"f.input:driving_time_hours,:label=>"DrivingTime(Hours)"f

ruby-on-rails - 注销前更新 current_user 时收到 "Attempted to update a stale object: User"异常

我在我的用户模型上启用了乐观锁定,以处理我代码库各个部分中可能发生的冲突。但是,我遇到了意外冲突,我不知道如何处理它,因为我不知道是什么原因造成的。我正在使用Devisegem进行身份验证,并且正在使用before_logout方法来重置安全token...classSessionsController:createbefore_filter:before_logout,:only=>:destroydefafter_login#logictosetthesecuritytokenenddefbefore_logoutcurrent_user.update(security_token

ruby-on-rails - 在 Rails 3 中使用 current_page 时为 "No routes matches"

有没有人遇到过使用current_page时路由神秘地变得无法检测到?在Rails3中?即使使用包含路由、View和Controller的完全生成的脚手架,我也会收到“无路由匹配”错误。代码如下:ifcurrent_page?(:controller=>'users',:action=>"show")如果我向routes.rb添加一个“匹配”命令,它工作正常,但如果资源已经创建,为什么我需要这样做呢?我错过了什么? 最佳答案 如果你只是想测试当前的Controller,你可以这样做:ifparams[:controller]=='u

ruby-on-rails - Mac OS X 山狮 "Rails is not currently installed on this system."

我正在全新安装OSXMountainLion。我通过以下方式安装了Rails:sudogeminstallrails一切似乎都安装正确,但是当我键入rails命令(railss、rails-v等)时,我收到此错误:Railsisnotcurrentlyinstalledonthissystem.Togetthelatestversion,simplytype:$sudogeminstallrailsYoucanthenrerunyour"rails"command.'whichrails'的结果是/usr/bin/rails我认为这是一个路径问题,也许是,但我可以看到/usr/bin是