TypeError: no implicit conversion of nil into String. utils.rb:24:in `quote_ident'
TypeError: no implicit conversion of nil into String. utils.rb:24:in `quote_ident'
我做了rake task
。
我的 rails 应用 运行 没有问题。
代码
namespace :i18n_master do
task check: :environment do
read_model
models = ActiveRecord::Base.descendants.map do |model|
next if model.name.nil?
model2hash(model)
end
p models
end
def model2hash(model)
return Hash[model.name, model.column_names]
end
def read_model
Dir[Rails.root.to_s + '/app/models/**/*.rb'].each do |file|
begin
require file
rescue
end
end
end
end
错误
** Invoke i18n_master:check (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute i18n_master:check
rake aborted!
TypeError: no implicit conversion of nil into String
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql/utils.rb:24:in `quote_ident'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql/utils.rb:24:in `quoted'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql/quoting.rb:31:in `quote_table_name'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:742:in `column_definitions'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql/schema_statements.rb:186:in `columns'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/schema_cache.rb:43:in `columns'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/attributes.rb:93:in `columns'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/model_schema.rb:260:in `column_names'
ror_app/lib/tasks/i18n_master.rake:13:in `model2hash'
ror_app/lib/tasks/i18n_master.rake:6:in `block (3 levels) in <top (required)>'
ror_app/lib/tasks/i18n_master.rake:4:in `map'
ror_app/lib/tasks/i18n_master.rake:4:in `block (2 levels) in <top (required)>'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/bin/rake:37:in `<main>'
Tasks: TOP => i18n_master:check
我读了这个
Rails 4.0.0 - Got "no implicit conversion of nil into String"
以上问题是gem for sqlite3
.
所以我认为我的问题是 gem for postgresql
。
但是我的 rails 应用 运行 没有问题.
我使用 bundle
。
% bundle pristine
Could not find command "pristine".
为什么
为什么 TypeError: no implicit conversion of nil into String
出现在 utils.rb:24:in quote_ident'
如何解决?
我明白了。
Globalize::ActiveRecord::Translation#column_names
出现这个错误。
所以,跳过这个。
namespace :i18n_master do
task check: :environment do
read_model
models = ActiveRecord::Base.descendants.map do |model|
next if model.name == 'Globalize::ActiveRecord::Translation'
model2hash(model)
end.compact
p models
end
def model2hash(model)
return Hash[model.name, model.column_names]
end
def read_model
Dir[Rails.root.to_s + '/app/models/**/*.rb'].each do |file|
begin
require file
rescue
end
end
end
end
我做了rake task
。
我的 rails 应用 运行 没有问题。
代码
namespace :i18n_master do
task check: :environment do
read_model
models = ActiveRecord::Base.descendants.map do |model|
next if model.name.nil?
model2hash(model)
end
p models
end
def model2hash(model)
return Hash[model.name, model.column_names]
end
def read_model
Dir[Rails.root.to_s + '/app/models/**/*.rb'].each do |file|
begin
require file
rescue
end
end
end
end
错误
** Invoke i18n_master:check (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute i18n_master:check
rake aborted!
TypeError: no implicit conversion of nil into String
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql/utils.rb:24:in `quote_ident'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql/utils.rb:24:in `quoted'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql/quoting.rb:31:in `quote_table_name'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:742:in `column_definitions'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql/schema_statements.rb:186:in `columns'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/schema_cache.rb:43:in `columns'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/attributes.rb:93:in `columns'
ror_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/model_schema.rb:260:in `column_names'
ror_app/lib/tasks/i18n_master.rake:13:in `model2hash'
ror_app/lib/tasks/i18n_master.rake:6:in `block (3 levels) in <top (required)>'
ror_app/lib/tasks/i18n_master.rake:4:in `map'
ror_app/lib/tasks/i18n_master.rake:4:in `block (2 levels) in <top (required)>'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/shingonakanishi/.rvm/rubies/ruby-2.2.3/bin/rake:37:in `<main>'
Tasks: TOP => i18n_master:check
我读了这个
Rails 4.0.0 - Got "no implicit conversion of nil into String"
以上问题是gem for sqlite3
.
所以我认为我的问题是 gem for postgresql
。
但是我的 rails 应用 运行 没有问题.
我使用 bundle
。
% bundle pristine
Could not find command "pristine".
为什么
为什么 TypeError: no implicit conversion of nil into String
出现在 utils.rb:24:in quote_ident'
如何解决?
我明白了。
Globalize::ActiveRecord::Translation#column_names
出现这个错误。
所以,跳过这个。
namespace :i18n_master do
task check: :environment do
read_model
models = ActiveRecord::Base.descendants.map do |model|
next if model.name == 'Globalize::ActiveRecord::Translation'
model2hash(model)
end.compact
p models
end
def model2hash(model)
return Hash[model.name, model.column_names]
end
def read_model
Dir[Rails.root.to_s + '/app/models/**/*.rb'].each do |file|
begin
require file
rescue
end
end
end
end