小编Adh*_*eeb的帖子

Rails 5 actioncable undefined方法`fetch'代表nil:NilClass

我正在使用Rails 5 actioncable并且在尝试发送任何引发的内容时出现此错误actioncable怎么办?我正在尝试将项目推向Heroku.

NoMethodError in MessagesController#create

undefined method `fetch' for nil:NilClass
Extracted source (around line #37):

#35       # Also makes sure proper dependencies are required.
#36       def pubsub_adapter
*37         adapter = (cable.fetch('adapter') { 'redis' })
#38         path_to_adapter = "action_cable/subscription_adapter/#{adapter}"
#39         begin
#40           require path_to_adapter

Extracted source (around line #50):

#48       # Adapter used for all streams/broadcasting.
#49       def pubsub
*50         @pubsub ||= config.pubsub_adapter.new(self)
#51       end
#52 
#53       # All the identifiers applied to the …
Run Code Online (Sandbox Code Playgroud)

websocket redis ruby-on-rails-5 actioncable

11
推荐指数
1
解决办法
2199
查看次数

rspec with mongoid,devise,database_cleaner:ActiveRecord :: ConnectionNotEstablished error

我正在尝试使用rspec与mongoid,devise,database_cleaner,我有这个错误

 Failure/Error: Unable to find matching line from backtrace
 ActiveRecord::ConnectionNotEstablished:
   ActiveRecord::ConnectionNotEstablished
 # /home/adham/.rvm/gems/ruby-2.1.5/gems/activerecord-4.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
 # /home/adham/.rvm/gems/ruby-2.1.5/gems/activerecord-4.1.8/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
 # /home/adham/.rvm/gems/ruby-2.1.5/gems/activerecord-4.1.8/lib/active_record/connection_handling.rb:87:in `connection'
 # /home/adham/.rvm/gems/ruby-2.1.5/gems/activerecord-4.1.8/lib/active_record/fixtures.rb:499:in `create_fixtures'
 # /home/adham/.rvm/gems/ruby-2.1.5/gems/activerecord-4.1.8/lib/active_record/fixtures.rb:984:in `load_fixtures'
 # /home/adham/.rvm/gems/ruby-2.1.5/gems/activerecord-4.1.8/lib/active_record/fixtures.rb:957:in `setup_fixtures'
 # /home/adham/.rvm/gems/ruby-2.1.5/gems/activerecord-4.1.8/lib/active_record/fixtures.rb:806:in `before_setup'
Run Code Online (Sandbox Code Playgroud)

我的gemfile测试组

group :development, :test do
    gem "factory_girl_rails", "~> 4.0"
  gem 'rspec-rails', '~> 3.1.0'
  gem 'spork', '~> 0.8.5'
  gem 'mongoid-rspec', '~> 2.0.0.rc1'
  gem 'capybara'
  gem 'database_cleaner'
  gem 'shoulda-matchers'
end
Run Code Online (Sandbox Code Playgroud)

和我的rails_helper.rb ==

ENV["RAILS_ENV"] ||= 'test'
require 'spec_helper'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require "mongoid"
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| …
Run Code Online (Sandbox Code Playgroud)

rspec ruby-on-rails devise mongoid database-cleaner

4
推荐指数
1
解决办法
695
查看次数

LoadError:libncursesw.so.5:无法打开共享对象文件:没有这样的文件或目录

当我尝试运行任何rake任务时,我正在使用Ruby 2.2.2Rails 4.2我有这个错误消息为什么会这样?我该怎么办?

  • Ruby 2.2.2
  • Rails 4.2
  • rbenv
  • Arch Linux
  • PostgreSQL数据库

错误信息

rake aborted! LoadError: libncursesw.so.5: cannot open shared object file: No such file or directory - /home/adham/.rbenv/versions/2.2.2/lib/ruby/2.2.0/x86_64-linux/readline.so /home/adham/.gem/ruby/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require' /home/adham/.gem/ruby/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require' /home/adham/.gem/ruby/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each' /home/adham/.gem/ruby/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require' /home/adham/.gem/ruby/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each' /home/adham/.gem/ruby/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require' /home/adham/.gem/ruby/2.2.0/gems/bundler-1.10.6/lib/bundler.rb:134:in `require' /home/code/kahareb/config/application.rb:7:in `<top (required)>' /home/code/kahareb/Rakefile:4:in `<top (required)>' (See full trace by running task with --trace)

ruby postgresql rake ruby-on-rails

4
推荐指数
1
解决办法
830
查看次数

Ruby on Rails 4.2.0 with rspec-rails 3.1.0 and shoulda-matchers 2.7.0 undefined method`validates_presence_of'for

我正在使用Ruby on Rails 4.2.0rspec-rails 3.1.0以及应用匹配器2.7.0

当运行测试我有这个错误

Failure/Error: it { should validates_presence_of :name }
     NoMethodError:
       undefined method `validates_presence_of' for #<RSpec::ExampleGroups::Profile::Vaidations:0x00000007881768>
     # ./spec/models/profile_spec.rb:5:in `block (3 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)

这是我的模特

class Profile < ActiveRecord::Base
  belongs_to :user
  accepts_nested_attributes_for :user
  validates :user, presence: true
  validates :username, presence: true, uniqueness: { case_sensitive: false }, length: {maximum: 50}
  validates :name, presence: true, length: {maximum: 50}
  validates :phone, presence: true, uniqueness: { case_sensitive: false }, length: {maximum: 50}
  validates :age, presence: true, …
Run Code Online (Sandbox Code Playgroud)

rspec ruby-on-rails shoulda rspec-rails

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