Solved

Rails uninitialized constant Iconv

Posted on 2009-05-03
5
2,131 Views
Last Modified: 2013-11-13
Hi there,

I'm having an issue with a RoR website : when trying to save a text change into the database i get the error below

Strange thing is that i imported the database from production where it is working well, under mysql on both development and production...

After being gone through some reasearch, i found this is most likely because of an encoding mismatch. But the encoding in the database.yml is the same in production and dev as well...

Any ideas ?
NameError in Admin/artistsController#update
 
uninitialized constant Iconv
 
RAILS_ROOT: script/../config/..
Application Trace | Framework Trace | Full Trace
 
vendor/rails/activesupport/lib/active_support/dependencies.rb:123:in `const_missing'
vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:78:in `urlnameify'
vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:85:in `attr_to_urlname'
vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:124:in `validate_urlname_against_class'
vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:117:in `validate_urlname'
vendor/rails/activerecord/lib/active_record/validations.rb:790:in `send'
vendor/rails/activerecord/lib/active_record/validations.rb:790:in `run_validations'
vendor/rails/activerecord/lib/active_record/validations.rb:788:in `each'
vendor/rails/activerecord/lib/active_record/validations.rb:788:in `run_validations'
vendor/rails/activerecord/lib/active_record/validations.rb:752:in `valid_without_callbacks'
vendor/rails/activerecord/lib/active_record/callbacks.rb:306:in `valid?'
vendor/rails/activerecord/lib/active_record/validations.rb:723:in `save_without_transactions'
vendor/rails/activerecord/lib/active_record/transactions.rb:126:in `save'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:91:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:118:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:126:in `save'
vendor/rails/activerecord/lib/active_record/base.rb:1439:in `update_attributes'
#{RAILS_ROOT}/app/controllers/admin/artists_controller.rb:45:in `update'
 
vendor/rails/activesupport/lib/active_support/dependencies.rb:123:in `const_missing'
vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:78:in `urlnameify'
vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:85:in `attr_to_urlname'
vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:124:in `validate_urlname_against_class'
vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:117:in `validate_urlname'
vendor/rails/activerecord/lib/active_record/validations.rb:790:in `send'
vendor/rails/activerecord/lib/active_record/validations.rb:790:in `run_validations'
vendor/rails/activerecord/lib/active_record/validations.rb:788:in `each'
vendor/rails/activerecord/lib/active_record/validations.rb:788:in `run_validations'
vendor/rails/activerecord/lib/active_record/validations.rb:752:in `valid_without_callbacks'
vendor/rails/activerecord/lib/active_record/callbacks.rb:306:in `valid?'
vendor/rails/activerecord/lib/active_record/validations.rb:723:in `save_without_transactions'
vendor/rails/activerecord/lib/active_record/transactions.rb:126:in `save'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:91:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:118:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:126:in `save'
vendor/rails/activerecord/lib/active_record/base.rb:1439:in `update_attributes'
vendor/rails/actionpack/lib/action_controller/base.rb:910:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:910:in `perform_action_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
vendor/rails/actionpack/lib/action_controller/rescue.rb:82:in `perform_action'
vendor/rails/actionpack/lib/action_controller/base.rb:381:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:381:in `process_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:377:in `process_without_session_management_support'
vendor/rails/actionpack/lib/action_controller/session_management.rb:117:in `process'
vendor/rails/railties/lib/dispatcher.rb:38:in `dispatch'
vendor/rails/railties/lib/webrick_server.rb:115:in `handle_dispatch'
vendor/rails/railties/lib/webrick_server.rb:81:in `service'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'
vendor/rails/railties/lib/webrick_server.rb:67:in `dispatch'
vendor/rails/railties/lib/commands/servers/webrick.rb:59
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
vendor/rails/activesupport/lib/active_support/dependencies.rb:147:in `require'
vendor/rails/railties/lib/commands/server.rb:30
script/server:3:in `require'
script/server:3
 
vendor/rails/activesupport/lib/active_support/dependencies.rb:123:in `const_missing'
vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:78:in `urlnameify'
vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:85:in `attr_to_urlname'
vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:124:in `validate_urlname_against_class'
vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:117:in `validate_urlname'
vendor/rails/activerecord/lib/active_record/validations.rb:790:in `send'
vendor/rails/activerecord/lib/active_record/validations.rb:790:in `run_validations'
vendor/rails/activerecord/lib/active_record/validations.rb:788:in `each'
vendor/rails/activerecord/lib/active_record/validations.rb:788:in `run_validations'
vendor/rails/activerecord/lib/active_record/validations.rb:752:in `valid_without_callbacks'
vendor/rails/activerecord/lib/active_record/callbacks.rb:306:in `valid?'
vendor/rails/activerecord/lib/active_record/validations.rb:723:in `save_without_transactions'
vendor/rails/activerecord/lib/active_record/transactions.rb:126:in `save'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:91:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:118:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:126:in `save'
vendor/rails/activerecord/lib/active_record/base.rb:1439:in `update_attributes'
#{RAILS_ROOT}/app/controllers/admin/artists_controller.rb:45:in `update'
vendor/rails/actionpack/lib/action_controller/base.rb:910:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:910:in `perform_action_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
vendor/rails/actionpack/lib/action_controller/rescue.rb:82:in `perform_action'
vendor/rails/actionpack/lib/action_controller/base.rb:381:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:381:in `process_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:377:in `process_without_session_management_support'
vendor/rails/actionpack/lib/action_controller/session_management.rb:117:in `process'
vendor/rails/railties/lib/dispatcher.rb:38:in `dispatch'
vendor/rails/railties/lib/webrick_server.rb:115:in `handle_dispatch'
vendor/rails/railties/lib/webrick_server.rb:81:in `service'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'
vendor/rails/railties/lib/webrick_server.rb:67:in `dispatch'
vendor/rails/railties/lib/commands/servers/webrick.rb:59
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
vendor/rails/activesupport/lib/active_support/dependencies.rb:147:in `require'
vendor/rails/railties/lib/commands/server.rb:30
script/server:3:in `require'
script/server:3
 
This error occured while loading the following files:
   active_record/acts/urlnameable/instance_methods/iconv.rb
 
Request
 
Parameters: {"artist"=>{"name"=>"Alexandra Maria Lara", "name_ja"=>"Alexandra Maria Lara", "name_fr"=>"Alexandra Maria Lara", "splash_image_temp"=>"", "bio_ja"=>"", "bio_fr"=>"V&eacute;ritable star en Allemagne, son pays d'adoption, cette jeune actrice d'origine roumaine a &eacute;t&eacute; rep&eacute;r&eacute;e dans <em>La Chute</em>, de Olivier Hirschbiegel ou encore dans <em>Control</em>, de Anton Corbijn.<br /> Apr&egrave;s un r&ocirc;le dans <em>L'homme sans &acirc;ge</em>, de Francis Ford Coppola, on la verra dans <em>The City of Your Final Destination</em>, de James Ivory. Elle vient &eacute;galement de tourner avec Spike Lee et Stephen Daldry (<em>Billy Elliot</em>).", "name_zh"=>"", "bio_zh"=>"", "splash_image"=>#<StringIO:0x1b6e4e0>, "bio"=>"", "artist_cat"=>"0"}, "commit"=>"Enregistrer", "id"=>"38"}
 
Show session dump
 
--- 
:authenticated: true
flash: !map:ActionController::Flash::FlashHash {}
 
 
Response
Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"}

Open in new window

0
Comment
Question by:terencepires
  • 3
  • 2
5 Comments
 
LVL 24

Expert Comment

by:fridom
ID: 24293639
Obviously on your development machine the Iconv library is not installed.

On Debian you can change that with apt-get install libiconv-ruby
or apt-get install ruby1.8-dev. That seems to be the most reasonable approach
for getting a bit more running on your System.

You may try your luck with a Gem install on other systems or check the
site of your distribution on how to get libiconv for Ruby

Regards
Friedrich

0
 
LVL 1

Author Comment

by:terencepires
ID: 24302839
Hi friedrich,

first off, thanks for your help !

i tried to reinstall iconv following your lead but it had no effect on my error....
I then found a tutorial here, which i tried too (it's in french) :
 
http://t37.net/ruby-iconv-et-freebsd-sont-dans-un-bateau.html 

sadly, it had no effect as well...

And when browsing the internet i can't seem to find anything addressing my issue...
0
 
LVL 1

Author Comment

by:terencepires
ID: 24302847
one more thing,
iconv.bundle was already installed in my version of Ruby.
0
 
LVL 24

Accepted Solution

by:
fridom earned 500 total points
ID: 24303965
The mentioned URL assumes that the development  files for iconv are installed. That seems to be not the case on your system. So check where you can get the headers and libraries for compiling iconv. So in fact my comment above still hold the development files for Iconv are not there. I can't tell where to get prebuld libraries for Mac, but mac is an Unix and so compiling iconf should be very doable...

Regards
Friedrich
0
 
LVL 1

Author Closing Comment

by:terencepires
ID: 31577349
thanks
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: narshlob
If you've ever programmed in Ruby and have come across either a proc or a lambda, you might have been wondering what the difference is between the two and when you would use one over the other. This article will try to explain the difference between…
In Ruby, Call or invoke a API DLL library is easily via Win32API class, win32-api gem or other gems. For general DLL API call, there are quite a few references, some good tips list below: http://www.rubytips.org/2008/05/13/accessing-windows-api-fro…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question