no 'jcode' gem when running rails server - ruby-on-rails

When I try to run 'rails server' it's giving me an error saying that it can't find 'jcode', and I think jcode is a default ruby lib.
Do you guys have any clue as to whats going on?
/Users/seanfchan/.rvm/gems/ruby-1.9.2-p0#global/gems/gdata-1.1.1/lib/gdata.rb:21:in `require': no such file to load -- jcode (LoadError)
from /Users/seanfchan/.rvm/gems/ruby-1.9.2-p0#global/gems/gdata-1.1.1/lib/gdata.rb:21:in `<top (required)>'
from /Users/seanfchan/.rvm/gems/ruby-1.9.2-p0#global/gems/contacts-1.2.4/lib/contacts/gmail.rb:1:in `require'
from /Users/seanfchan/.rvm/gems/ruby-1.9.2-p0#global/gems/contacts-1.2.4/lib/contacts/gmail.rb:1:in `<top (required)>'
from /Users/seanfchan/.rvm/gems/ruby-1.9.2-p0#global/gems/contacts-1.2.4/lib/contacts.rb:6:in `require'
from /Users/seanfchan/.rvm/gems/ruby-1.9.2-p0#global/gems/contacts-1.2.4/lib/contacts.rb:6:in `<top (required)>'
from /Users/seanfchan/.rvm/gems/ruby-1.9.2-p0#global/gems/bundler-1.0.3/lib/bundler/runtime.rb:64:in `require'
from /Users/seanfchan/.rvm/gems/ruby-1.9.2-p0#global/gems/bundler-1.0.3/lib/bundler/runtime.rb:64:in `block (2 levels) in require'
from /Users/seanfchan/.rvm/gems/ruby-1.9.2-p0#global/gems/bundler-1.0.3/lib/bundler/runtime.rb:62:in `each'
from /Users/seanfchan/.rvm/gems/ruby-1.9.2-p0#global/gems/bundler-1.0.3/lib/bundler/runtime.rb:62:in `block in require'
from /Users/seanfchan/.rvm/gems/ruby-1.9.2-p0#global/gems/bundler-1.0.3/lib/bundler/runtime.rb:51:in `each'
from /Users/seanfchan/.rvm/gems/ruby-1.9.2-p0#global/gems/bundler-1.0.3/lib/bundler/runtime.rb:51:in `require'
from /Users/seanfchan/.rvm/gems/ruby-1.9.2-p0#global/gems/bundler-1.0.3/lib/bundler.rb:112:in `require'
from /Users/seanfchan/RubyPractice/gettingContancts/config/application.rb:7:in `<top (required)>'
from /Users/seanfchan/.rvm/gems/ruby-1.9.2-p0#global/gems/railties-3.0.1/lib/rails/commands.rb:28:in `require'
from /Users/seanfchan/.rvm/gems/ruby-1.9.2-p0#global/gems/railties-3.0.1/lib/rails/commands.rb:28:in `block in <top (required)>'
from /Users/seanfchan/.rvm/gems/ruby-1.9.2-p0#global/gems/railties-3.0.1/lib/rails/commands.rb:27:in `tap'
from /Users/seanfchan/.rvm/gems/ruby-1.9.2-p0#global/gems/railties-3.0.1/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
System: Mac OSx Snow Leopard
Ruby: RVM 1.9.2
Rails: 3.0.1
Gem: 1.3.7
trying to use 'contacts' gem
Thanks,
Sean Chan

Sounds like the library you're using wasn't updated for Ruby 1.9.
Ruby >= 1.9 doesn't have jcode, a module to handle japanese (EUC/SJIS) strings, as it supports unicode natively.
You may want to see of a newer version of the library is available, otherwise you can look at the source and find where it is requiring jcode, and replace it with
require 'jcode' if RUBY_VERSION < '1.9'

We should check the lib folder which is presented under the gdata gem file.
Add this line:
require 'jcode' if RUBY_VERSION < '1.9'
in the lib/gdata.rb file.

Other solution, put this in your gemfile:
gem 'gdata_19', '1.1.5'
gem 'contacts', :git => 'git#github.com:eofferma/contacts.git'

Related

Rails 6.1, Ruby 3.0.0: tests error as they cannot load rexml

I've created a new Rails 6.1 application from scratch with Ruby 3.0.0.
I've run db:create and generated a single model with some string columns, followed by rails db:migrate.
I ran rails test but got this require rexml error:
/Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:34:in `require': cannot load such file -- rexml/document (LoadError)
from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `block in require'
from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:299:in `load_dependency'
from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `require'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/firefox.rb:22:in `<main>'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `block in require'
from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:299:in `load_dependency'
from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `require'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/webdrivers-4.4.1/lib/webdrivers/geckodriver.rb:72:in `<main>'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `block in require'
from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:299:in `load_dependency'
from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `require'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/webdrivers-4.4.1/lib/webdrivers.rb:4:in `<main>'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:66:in `block (2 levels) in require'
from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:61:in `each'
from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:61:in `block in require'
from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:50:in `each'
from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:50:in `require'
from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler.rb:174:in `require'
from /Users/froop/Rails/froop_app/config/application.rb:7:in `<top (required)>'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/application.rb:92:in `require'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/application.rb:92:in `preload'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `run'
from /Users/froop/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>'
from <internal:/Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from -e:1:in `<main>'
I'm not at all sure what's causing this. Rails is up to date. Can anyone point me in the right direction?
rexml gem is a bundled gem since Ruby 3.0.0.
So you must add rexml to Gemfile.
On Ruby 2.6 and 2.7, rexml gem is default gem.
So default rexml is used if Gemfile does not include rexml.
On these versions of ruby, you must add rexml to Gemfile only if you want to use specific rexml version.
To install rexml just paste: gem 'rexml', '~> 3.2', '>= 3.2.4' in Gemfile. You can find it at https://rubygems.org/gems/rexml
Why is it happening now?
Ruby has been going through a process of Gemifying Ruby - breaking up Ruby from a standard library to Gems.
In Ruby 2.7 rexml gem is a 'default gem' which means that it could not be removed and could be required without declaring them as dependencies in Gemfiles.
In Ruby 3.0 rexml gem is a 'bundled gem':
Bundled gems are regular gems that ship with the default Ruby
installation. These libraries are maintained outside the Ruby core
team and can be uninstalled if necessary. As with other 3rd-party
gems, you have to include them into gemspec or gemfile.
Blog article by strzibny - What are default and bundled gems in Ruby anyway?
So, in Ruby 3.0.0 changed to a bundled gem (from being default Gem in 2.7) so if it is used it must be added to the Gemfile.

Bcrypt gem in Ruby on Rails

I've just created a fresh Rails 5 application. I don't have any MVC's generated yet inside my application.
I added some gems to the gem file including gem 'bcrypt', '3.1.11'.
When I try to create a controller with the rails generator, I get an error.
This is the command with the error that I got:
command>rails generate controller StaticPages home help
C:/Ruby23/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/bcrypt.rb:16:in `require': cannot load such file -- bcrypt_ext (LoadError)
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/bcrypt.rb:16:in `rescue in <top (required)>'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/bcrypt.rb:12:in `<top (required)>'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:91:in `require'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `each'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `block in require'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `each'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `require'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler.rb:106:in `require'
from C:/Users/Doesha/Desktop/rails17/rails_sample_app/config/application.rb:7:in `<top (required)>'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:156:in `require'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:156:in `require_application_and_environment!'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:143:in `generate_or_destroy'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:60:in `generate'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
All I did was add gems to my gemfile, so I'm not sure why the rails generator isn't working.
I did notice that my generator stops working when I add the gem bcrypt.
Can someone tell me the reason I can't use my generator once I installed gem 'bcrypt', '3.1.11'?
delete gem 'bcrypt', '3.1.11' from gem file and
use
$gem install bcrypt

Ruby on rails server not starting: bundler-1.14.6 `require': cannot load such file

Upgrading and old Ruby on rails app from ruby 1.9.3-p545 to ruby 2.3.1. on development server.
Rails 3.2.8 will be upgraded to 4.2.8 (not done yet).
RVM and ruby version upgraded to 2.3.1, bundle installed successfully.
The following error occurs when running development server:
/home/javier/.rvm/gems/ruby-2.3.1/gems/activesupport-3.2.8/lib/active_support/values/time_zone.rb:270: warning: circular argument reference - now
/home/javier/.rvm/gems/ruby-2.3.1/gems/bundler-1.14.6/lib/bundler/runtime.rb:91:in `require': cannot load such file -- zip/zip (LoadError)
from /home/javier/.rvm/gems/ruby-2.3.1/gems/bundler-1.14.6/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
from /home/javier/.rvm/gems/ruby-2.3.1/gems/bundler-1.14.6/lib/bundler/runtime.rb:86:in `each'
from /home/javier/.rvm/gems/ruby-2.3.1/gems/bundler-1.14.6/lib/bundler/runtime.rb:86:in `block in require'
from /home/javier/.rvm/gems/ruby-2.3.1/gems/bundler-1.14.6/lib/bundler/runtime.rb:75:in `each'
from /home/javier/.rvm/gems/ruby-2.3.1/gems/bundler-1.14.6/lib/bundler/runtime.rb:75:in `require'
from /home/javier/.rvm/gems/ruby-2.3.1/gems/bundler-1.14.6/lib/bundler.rb:107:in `require'
from /home/javier/Workspace/e-nrg/config/application.rb:7:in `<top (required)>'
from /home/javier/.rvm/gems/ruby-2.3.1/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require'
from /home/javier/.rvm/gems/ruby-2.3.1/gems/railties-3.2.8/lib/rails/commands.rb:53:in `block in <top (required)>'
from /home/javier/.rvm/gems/ruby-2.3.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
from /home/javier/.rvm/gems/ruby-2.3.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I think that you can fix your problem as:
gem 'rubyzip', "~> 1.1", require: 'zip'

Error while installing gem in Ruby on Rails project

I created a simple web project in ROR - postgresql as a DB
C:\Sites\nested>ruby -v
ruby 1.9.3p484 (2013-11-22) [i386-mingw32]
C:\Sites\nested>rails -v
Rails 4.0.2
When I try to add an automatic foreign key either by command line
C:\Sites\nested>gem install automatic_foreign_key
or edit the gem file by adding
# create automatic foreign key
gem "automatic_foreign_key", "~> 1.3.0"
I got the following error when running the server
C:\Sites\nested>rails s
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.0.2/lib/active_support/core_ext/module/aliasing.rb:32:in `alias_method': undefined method `to_sql' for class `ActiveRecord::ConnectionAdapters::Tab leDefinition' (NameError)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-.0.2/lib/active_support/core_ext/module/aliasing.rb:32:in `alias_method_chain'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/redhillonrails_core-.2.0/lib/redhillonrails_core/active_record/connection_adapters/table_definition.rb:9:in `block in included'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/redhillonrails_core-.2.0/lib/redhillonrails_core/active_record/connection_adapters/table_definition.rb:6:in `class_eval'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/redhillonrails_core-.2.0/lib/redhillonrails_core/active_record/connection_adapters/table_definition.rb:6:in `included'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/redhillonrails_core-.2.0/lib/redhillonrails_core.rb:32:in `include'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/redhillonrails_core-.2.0/lib/redhillonrails_core.rb:32:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-.0.2/lib/active_support/dependencies.rb:229:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-.0.2/lib/active_support/dependencies.rb:229:in `block in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-.0.2/lib/active_support/dependencies.rb:229:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/automatic_foreign_key-.3.0/lib/automatic_foreign_key.rb:5:in `rescue in <top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/automatic_foreign_key-.3.0/lib/automatic_foreign_key.rb:1:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-.3.5/lib/bundler/runtime.rb:72:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-.3.5/lib/bundler/runtime.rb:70:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-.3.5/lib/bundler/runtime.rb:70:in `block in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-.3.5/lib/bundler/runtime.rb:59:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-.3.5/lib/bundler/runtime.rb:59:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-.3.5/lib/bundler.rb:132:in require'
from C:/Sites/nested/config/application.rb:7:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-.0.2/lib/rails/commands.rb:74:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-.0.2/lib/rails/commands.rb:74:in `block in <top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-.0.2/lib/rails/commands.rb:71:in `tap'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-.0.2/lib/rails/commands.rb:71:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
FYI this is your error:
`alias_method': undefined method `to_sql' for class `ActiveRecord::ConnectionAdapters::Tab leDefinition' (NameError)
Looks like the gem is creating an alias_method for .to_sql. Alias method basicaly calls a method by another name, so you can use it in different contexts
We use alias_method :name, :title a lot, because we standardize our validations, meaning we need to keep the same method names each time
Error
The actual error is caused by your class not having the to_sql method. I've never encountered this, so I looked it up:
Seems the issue is caued by Rails 4. As for a solution, I would suggest that since automatic_foreign_key hasn't been updated since 2011, it's going to be incompatible with Rails 4
If we take that idea as the problem, maybe you could detail how you want it to work & we could create a work-around?
try this
C:\Sites\nested>gem install --local automatic_foreign_key
and also bundle install --local in your project terminal and then edit gem "automatic_foreign_key", "~> 1.3.0" in your gem file

deprecated_mass_assignment_security.rb:14:in `attr_accessible' [voting gem][rails 4]

So, when running
[leap_staging]$rails g reputation_system
After including the gem 'activerecord-reputation-system', require: 'reputation_system' in my Gemfile I get the below error:
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activemodel-4.0.0/lib/active_model/deprecated_mass_assignment_security.rb:14:in `attr_accessible': `attr_accessible` is extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or add `protected_attributes` to your Gemfile to use old one. (RuntimeError)
from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-reputation-system-2.0.2/lib/reputation_system/models/evaluation.rb:25:in `<class:Evaluation>'
from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-reputation-system-2.0.2/lib/reputation_system/models/evaluation.rb:18:in `<module:ReputationSystem>'
from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-reputation-system-2.0.2/lib/reputation_system/models/evaluation.rb:17:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-reputation-system-2.0.2/lib/reputation_system.rb:25:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p195#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /usr/local/rvm/gems/ruby-2.0.0-p195#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /usr/local/rvm/gems/ruby-2.0.0-p195#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /usr/local/rvm/gems/ruby-2.0.0-p195#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from /usr/local/rvm/gems/ruby-2.0.0-p195#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /usr/local/rvm/gems/ruby-2.0.0-p195#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /usr/local/rvm/gems/ruby-2.0.0-p195#global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from /Users/apane/Downloads/leap_staging/leap_staging/config/application.rb:7:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/railties-4.0.0/lib/rails/commands.rb:44:in `require'
from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/railties-4.0.0/lib/rails/commands.rb:44:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
It's clear to me that this had to with Rails 4 and the new Strong Params. However, I'd like to get this workin'. So, how can I get this to work or convert it to strong_params if I can't even generate the files?
See the full app here if necessary for easy troubleshooting: www.github.com/apane/leap (gem not included)
Have you tried adding the protected_attributes Gem into your Gemfile like the message says?
activerecord-reputation-system gem now supports Rails 4 (since version 3.0).

Resources