小编use*_*363的帖子

在rspec中flash [:notice] .should_not be_nil失败

这是控制器的rspec代码:

it "should render edit if update was not saved" do
  item = Factory(:lease_item)
  session[:corp_head] = true
  post 'update', {:id => item.id, :name => 'nil'}
  flash[:notice].should_not be_nil
  response.should render 'edit'    
end
Run Code Online (Sandbox Code Playgroud)

控制器中的更新是:

  def update
    if (eng? && dept_head?) || corp_head? || ceo?
      @lease_item = LeaseItem.find(params[:id])
      @lease_item.input_by_id = session[:user_id]
      if @lease_item.update_attributes(params[:lease_item], :as => :roles_update)

        #redirect
        redirect_to URI.escape("/view_handler?index=0&msg=Lease item updated successfully")
      else
        #back to new
        render 'edit', :notice => "Item NOT updated"
      end
    else
      #back to previous page
      redirect_to URI.escape("/view_handler?index=0&msg=NO right to …
Run Code Online (Sandbox Code Playgroud)

rspec ruby-on-rails

6
推荐指数
1
解决办法
2万
查看次数

PG :: NotNullViolation:ERROR:列"id"中的空值违反非空约束

将记录保存到rails 3.2.12&pg 9.3中的postgres数据库时出现错误:

ActiveRecord::StatementInvalid (PG::NotNullViolation: ERROR:  null value in column "id" violates not-null constraint
: INSERT INTO "sw_module_infox_module_infos" ("about_controller", "about_init", "about_log", "about_misc_def", "about_model", "about_onboard_data", "about_subaction", "about_view", "about_workflow", "active", "api_spec", "category_id", "created_at", "last_updated_by_id", "module_desp", "name", "submit_date", "submitted_by_id", "updated_at", "version", "wf_state") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21) RETURNING "id"):
  activerecord (3.2.12) lib/active_record/connection_adapters/postgresql_adapter.rb:1166:in `get_last_result'
  activerecord (3.2.12) lib/active_record/connection_adapters/postgresql_adapter.rb:1166:in `exec_cache'
Run Code Online (Sandbox Code Playgroud)

该表工作正常至今(在今天的错误之前保存了大约50条记录).在pgadmin中打开pg表后.我们发现id桌上的是integer.我们Id在其他表上也发现了serial.似乎id应该是 …

postgresql ruby-on-rails

6
推荐指数
2
解决办法
1万
查看次数

有没有destroy_all!/ delete_all!在Rails?

我们正在寻找删除Rails中多个记录的命令transaction.为了使内触发transaction,我们使用destroy_all!delete_all!并收到method not defined错误.在Rails事务中触发的多个记录的正确删除命令(或正确的方法)是什么?

ruby-on-rails-4

6
推荐指数
1
解决办法
4260
查看次数

I18n.t并不总是加载Rails开发

I18n.t我们的Rails 4.2应用程序在开发过程中出现了奇怪的行为.直到最近,I18n.t都没有问题.如果不更改应用程序的配置,I18n.t不会在开发中加载.有时页面会自行刷新并加载翻译.但是大多数时候,translation missing每一个都有错误I18n.t.

这是local.rb初始化器:

I18n.enforce_available_locales = false
I18n.default_locale = 'zh-CN' if Rails.env.production? || Rails.env.development?
I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
Run Code Online (Sandbox Code Playgroud)

在生产环境中I18n.t没有问题.有人以前看过这个问题吗?问题的原因是什么?

internationalization ruby-on-rails-4

6
推荐指数
1
解决办法
101
查看次数

未捕获的异常:无法加载此类文件 - rails_helper

这是调试(Aptana 3.6.1)rspec(v3.4.1)案例时的错误.

Fast Debugger (ruby-debug-ide 0.6.0, debase 0.2.1, file filtering is supported) listens on 127.0.0.1:54432
Uncaught exception: cannot load such file -- rails_helper
    C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:121:in `require'
    C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:121:in `require'
    C:/D/code/rails_proj/engines/simple_orderx/spec/controllers/simple_orderx/orders_controller_spec.rb:1:in `<top (required)>'
    C:/Ruby22-x64/bin/rdebug-ide:23:in `load'
    C:/Ruby22-x64/bin/rdebug-ide:23:in `<main>'
Run Code Online (Sandbox Code Playgroud)

该错误是由spec文件中的行引起的:

require "rails_helper"
Run Code Online (Sandbox Code Playgroud)

如果更改为require "spec_helper",则错误变为can not load spec_helper.

#121行代码kernel_require.rb

return gem_original_require(path)
Run Code Online (Sandbox Code Playgroud)

这里path返回"rails_helper".它似乎不知道应用程序的根目录在哪里.试图使用"spec/rails_helper",错误是一样的.但是bundle exec rspec spec在app的root下运行时没有错误.rspec版本是3.4.1,rails 4.2和ruby 2.2.3.IDE是Aptana 3.6.1.

ruby-on-rails rspec-rails

6
推荐指数
0
解决办法
752
查看次数

在ubuntu 14.04上使用passenger-install-nginx-module的Bundler错误

我在ubuntu 14.04&上安装了乘客+ nginx ruby 2.2.4.有bundler错误passenger-install-nginx-module

  $passenger-install-nginx-module
    /home/ubuntu/.rvm/gems/ruby-2.2.4/gems/bundler-1.13.1/lib/bundler/rubygems_ext.rb:45:in `full_gem_path': uninitialized constant Bundler::Plugin::API::Source (NameError)
            from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/basic_specification.rb:144:in `block in full_require_paths'
            from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/basic_specification.rb:143:in `map'
            from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/basic_specification.rb:143:in `full_require_paths'
            from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/basic_specification.rb:76:in `contains_requirable_file?'
            from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:949:in `block in find_in_unresolved'
            from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:949:in `each'
            from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:949:in `find_all'
            from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:949:in `find_in_unresolved'
            from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:74:in `require'
            from /home/ubuntu/.rvm/gems/ruby-2.2.4/gems/bundler-1.13.1/lib/bundler/plugin/api/source.rb:2:in `<top (required)>'
            from /home/ubuntu/.rvm/gems/ruby-2.2.4/gems/bundler-1.13.1/lib/bundler/rubygems_ext.rb:45:in `full_gem_path'
            from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/basic_specification.rb:144:in `block in full_require_paths'
            from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/basic_specification.rb:143:in `map'
            from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/basic_specification.rb:143:in `full_require_paths'
            from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:1370:in `add_self_to_load_path'
            from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:1283:in `activate'
            from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_gem.rb:67:in `block in gem'
            from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_gem.rb:66:in …
Run Code Online (Sandbox Code Playgroud)

ruby ubuntu ruby-on-rails passenger nginx

6
推荐指数
2
解决办法
1900
查看次数

statsmodels安装:numpy.distutils中没有名为“ numpy.distutils._msvccompiler”的模块;从distutils尝试

这似乎是一个普遍的问题,但是所有答案似乎都没有帮助。statsmodels在Windows 10中安装时(安装了python 3.6.2),该错误会弹出:

python setup.py install
Run Code Online (Sandbox Code Playgroud)

在此之前,numpy已安装:

python numpy install
Run Code Online (Sandbox Code Playgroud)

没有错误,我认为这是成功的。但是的安装statsmodels仍然存在statsmodels安装错误。

我确实安装了MS c ++编译器(2015)。我也安装了最新的Anaconda(python 3.6.1),但没有帮助。以下是已安装的VC ++编译器的列表。

在此处输入图片说明

python numpy statsmodels

6
推荐指数
1
解决办法
1万
查看次数

使用React Native 0.59.5删除警告viewPagerAndroid

升级到后react native 0.59.5,该应用在模拟器上引发了以下警告消息:

viewPagerAndroid has been extracted from react-native core...
Run Code Online (Sandbox Code Playgroud)

但是viewPagerAndroid在组件文件中没有导入:

import React, { Component} from 'react';
import { SectionList, View, StyleSheet, Text, TouchableOpacity, Platform, AppRegistry } from 'react-native';
import Moment from 'moment';
import DeviceInfo from 'react-native-device-info';
import { GiftedChat } from 'react-native-gifted-chat';
Run Code Online (Sandbox Code Playgroud)

如何删除警告?

react-native

6
推荐指数
1
解决办法
2898
查看次数

类型错误:未定义不是函数,js引擎:hermes

我的 React Native (0.66.3) 应用程序今天弹出一个错误,其中的稳定代码已经很长一段时间没有任何更改了。它位于 macOS Big Sur 上。这是错误:

 ERROR  TypeError: undefined is not a function, js engine: hermes
Error: ENOENT: no such file or directory, open '/Users/macair/Documents/code/js/xyz_app5/http:/localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.xyz-app5'
    at Object.openSync (fs.js:498:3)
    at Object.readFileSync (fs.js:394:35)
    at getCodeFrame (/Users/macair/Documents/code/js/xyz_app5/node_modules/metro/src/Server.js:919:18)
    at Server._symbolicate (/Users/macair/Documents/code/js/xyz_app5/node_modules/metro/src/Server.js:992:22)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Server._processRequest (/Users/macair/Documents/code/js/xyz_app5/node_modules/metro/src/Server.js:403:7) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/Users/macair/Documents/code/js/xyz_app5/http:/localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.xyz-app5'
}
Run Code Online (Sandbox Code Playgroud)

这是IOS模拟器上显示的错误:

在此输入图像描述

该错误似乎与 React Native 中的 Metro 相关。

react-native metro-bundler react-native-hermes

6
推荐指数
1
解决办法
1万
查看次数

Android 构建错误:在 build/kotlin/sessions 检测到多个 Kotlin 守护进程会话

在构建发布包之前,我按照 React Native0.67.4 指令生成密钥并签署配置。该应用程序在 Android 模拟器 (Android Studio) 中运行良好2120.1.1 Patch2。但是在构建发布包时,两者./gradlew assembleRelease都有./gradlew bundleRelease相同的错误,如下所示:

任务:app:signReleaseBundle失败

w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:signReleaseBundle'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.FinalizeBundleTask$BundleToolRunnable
   > java.lang.NullPointerException (no error message)
Run Code Online (Sandbox Code Playgroud)

尝试了帖子中的以下内容

  1. 删除了 ./gradle 下的所有内容和yarn run android
  2. ./gradlew clean 多次

Android studio 2021.1.1 Patch2,Gradle React Native 插件版本 7.2.1/(gradle 7.4.1)

这是其中的一部分package.json …

android-studio react-native

6
推荐指数
1
解决办法
6300
查看次数