Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails migration error with thumbs_up gem

I am using the thumbs_up gem to create a voting system. I am using PostgreSQL. When I run:

rails generate thumbs_up

I get the following error:

/usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thumbs_up-0.6.7/lib/generators/thumbs_up/thumbs_up_generator.rb:21:in `create_migration': wrong number of arguments (3 for 0) (ArgumentError)
    from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/railties-4.0.4/lib/rails/generators/migration.rb:65:in `migration_template'
    from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thumbs_up-0.6.7/lib/generators/thumbs_up/thumbs_up_generator.rb:22:in `create_migration'
    from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
    from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
    from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
    from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
    from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
    from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/railties-4.0.4/lib/rails/generators.rb:156:in `invoke'
    from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/railties-4.0.4/lib/rails/commands/generate.rb:11:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
    from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `block in require'
    from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
    from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/railties-4.0.4/lib/rails/commands.rb:48:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

How do I fix this?

like image 805
Philip7899 Avatar asked Jan 23 '26 02:01

Philip7899


2 Answers

This is a bug in thumbs_up.

Check this issue on github: https://github.com/bouchard/thumbs_up/issues/96

I stumbled across the same error and fixed it with the help of the link above.

Apparently all you have to do is change a file in the thumbs_up gem (you will find the location of that gem in the error itself).

In file [path to gem]/lib/generators/thumbs_up/thumbs_up_generator.rb replace

def create_migration
  migration_template 'migration.rb', File.join('db', 'migrate', 'thumbs_up_migration.rb')
end

with

def create_thumbs_up_migration
  migration_template 'migration.rb', File.join('db', 'migrate', 'thumbs_up_migration.rb')
end
like image 99
brett Avatar answered Jan 25 '26 19:01

brett


in your Gemfile require the gem this way:

gem 'thumbs_up', git: 'https://github.com/bouchard/thumbs_up.git', ref: 'f499a7c803c0a9fdcefe4275f2f0a10ca7964508'

then run

rails generate thumbs_up 

This should work. Worked for me - hope this helps....

like image 32
ARTLoe Avatar answered Jan 25 '26 20:01

ARTLoe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!