jjzjj

not-operator

全部标签

ruby-on-rails - ruby rails : rails generate controller does not work

我是ruby​​和rails的新手,我在生成Controller时遇到了问题。一些上下文:$rails-vRails4.1.1应用已正确创建:$railsnewtest_appcreatecreateREADME.rdoccreateRakefilecreateconfig.rucreate.gitignorecreateGemfilecreateapp[...]Yourbundleiscomplete!Use`bundleshow[gemname]`toseewhereabundledgemisinstalled.runbundleexecspringbinstub--all*bin

ruby-on-rails - rails : Detecting user agent works in development but not production?

我正在尝试在我的应用程序中检测黑莓用户代理,这在我的开发版本中运行良好。但是当我在生产环境中重新部署该应用程序时,没有任何反应。application_helper.rbdefblackberry_user_agent?request.env["HTTP_USER_AGENT"]&&request.env["HTTP_USER_AGENT"][/(Blackberry)/]end应用程序.html.erbUsingaBlackberry?Usethemobileoptimizedversion.我已经尝试使用raketmp:cache:clear清除缓存并重新启动mongrel几次。显

ruby-on-rails - Rails 日志文件 "not opened for writing"

我正在将我的应用程序从ruby​​1.8.7迁移到1.9.3(然后升级Rails)。但是我在登录1.9.3时遇到了一些问题。通过在控制台或服务器启动时在environment.rb中使用以下代码logfile=File.open(File.join(RAILS_ROOT,'/log/call_log.log'),'a')CALL_LOGGER=AuditLogger.new(logfile)CALL_LOGGER.info"CALL_LOGGER:Serverstarted."我明白了/usr/local/rvm/scripts/irbrc.rb:32:in`write':notope

ruby-on-rails - pg_search 使用 associated_against 给出错误 "column [model_name].[associated_column_name] does not exist"

我正在尝试使用pg_search来搜索关联模型。当我运行搜索时,出现错误“PG::Error:ERROR:columnplans.namedoesnotexist”。我正在“计划”模型中运行搜索,并尝试针对“地点”与列“名称”的关联进行搜索。连接这些的has_many:through模型是多态的。不知何故,sql查询将两者结合起来并抛出错误。我已经运行了associated_against迁移(railsgpg_search:migration:associated_against),搜索了文档,并寻找其他有错误的人,但一无所获,一定是我只是忽略了一些东西。如果我只是删除plan.rb

ruby-on-rails - rake 数据库 :migrate not working on my postgres db

好的,所以我有一个Rails应用程序,我试图在postgres数据库上运行迁移,我通常使用mysql,一切都很好,但是当我运行命令时,我得到了这个rakedb:migrate(in/Users/tamer/Sites/my_app)/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:487:[BUG]Segmentationfaultruby1.9.2p290(2011-07-09

ruby-on-rails - Rails 国际化 : %{record} is not being translated

我的rails.pt-BR.yml上有这个:br:errors:format:!'%{attribute}%{message}'messages:restrict_dependent_destroy:one:"Nãoépossívelexcluiroregistropoisexisteum%{record}dependente"many:"Nãoépossívelexcluiroregistropoisexistem%{record}dependentes"在我的模型中,我有这个:has_many:entities,dependent::restrict_with_error每当res

ruby - 如何在 Chef Recipe 中使用 not_if

我是Chef的新手,所以我对条件not_if在执行资源中的工作方式有些困惑。我知道如果命令返回0或true,它会告诉Chef不要执行命令;但是,在我的代码中,它显然仍在运行命令。下面的代码应该创建一个用户(及其密码)和一个数据库;然而,如果用户和数据库已经存在,它不应该做任何事情。用户、数据库和密码在属性中定义。以下是我的代码:execute"create-user"docode=Chef给我以下错误:在资源“execute[create-user]”上执行操作run时出错...[2013-01-25T12:24:51-08:00]致命:Mixlib::ShellOut::ShellC

ruby-on-rails - Rails 3.2 ActiveAdmin 'Collection is not a paginated scope.' 错误

我正在使用Rails3.2和ActiveAdmin0.4.4开发应用程序。我有一个名为Teaser的模型(/app/models/teaser.rb):classTeasertruemount_uploader:img,TeaserUploaderend然后我向其中添加了ActiveAdmin(/app/admin/teaser.rb):#encoding:UTF-8ActiveAdmin.registerTeaserdoformdo|f|f.inputs"Teaser"dof.input:name,:label=>'Текст'f.input:url,:label=>'Ссылка'

ruby-on-rails - rails : why is calling to_a on a string not valid in a rake task?

我正在尝试解密一组用于数据库迁移的密码。我有一些旧的Rails代码(实际上是一个Runner脚本)可以很好地解密它们。但是将相同的代码放入Rake任务会导致任务失败,并显示...未定义的方法`to_a'for"secretkey":String...为什么在字符串上调用to_a在Rake任务中无效,但在Runner脚本中却完全有效?require'openssl'KEY='secretkey'namespace:importdotask:users=>:environmentdodefdecrypt_password(pw)cipher=OpenSSL::Cipher::Cipher.

ruby-on-rails - 从设计 "User does not respond to ' 设计方法中获取错误“运行 "rails generate devise:install"时

当运行“railsgeneratedevise:install”时,我从设计中收到错误“用户不响应‘设计’方法”。想法重新如何解决?事实上,当我尝试运行“railsgeneratedevise:install”时,我也注意到了这个错误。注意事项:Gregs-MacBook-Pro:testappgreg$railsgeneratedevise:install/Library/Ruby/Gems/1.8/gems/devise-2.0.1/lib/devise/rails/routes.rb:406:in`raise_no_devise_method_error!':Userdoesno