4

I am working with Rails 5.0.0.beta3 and creating a rails-api. when i run

rails-api generate scaffold user email:string password:string auth_token:string

it shows the error

.rvm/gems/ruby-2.2.3/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'rails-api'. (Bundler::GemRequireError)
from /home/ahsanul/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/ahsanul/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
from /home/ahsanul/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
from /home/ahsanul/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
from /home/ahsanul/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
from /home/ahsanul/.rvm/gems/ruby-2.2.3/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
from /home/ahsanul/Documents/rails-api/my_blog/config/application.rb:7:in `<top (required)>'
from /home/ahsanul/.rvm/gems/ruby-2.2.3/gems/spring-1.7.1/lib/spring/application.rb:82:in `require'
from /home/ahsanul/.rvm/gems/ruby-2.2.3/gems/spring-1.7.1/lib/spring/application.rb:82:in `preload'
from /home/ahsanul/.rvm/gems/ruby-2.2.3/gems/spring-1.7.1/lib/spring/application.rb:143:in `serve'
from /home/ahsanul/.rvm/gems/ruby-2.2.3/gems/spring-1.7.1/lib/spring/application.rb:131:in `block in run'
from /home/ahsanul/.rvm/gems/ruby-2.2.3/gems/spring-1.7.1/lib/spring/application.rb:125:in `loop'
from /home/ahsanul/.rvm/gems/ruby-2.2.3/gems/spring-1.7.1/lib/spring/application.rb:125:in `run'
from /home/ahsanul/.rvm/gems/ruby-2.2.3/gems/spring-1.7.1/lib/spring/application/boot.rb:19:in `<top (required)>'
from /home/ahsanul/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/ahsanul/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'

How can i resolve the problem?

7
  • bundle install in console
    – Ilya
    Apr 13, 2016 at 12:05
  • Not working. Same problem
    – Ahsan
    Apr 13, 2016 at 12:09
  • have you tried bundle update?
    – mtrolle
    Apr 13, 2016 at 12:13
  • yes. bundle update, bundle, same error @mtrolle
    – Ahsan
    Apr 13, 2016 at 12:13
  • Could you show what your Gemfile looks like ?
    – VonD
    Apr 13, 2016 at 12:15

3 Answers 3

5

You don't need to include rails-api gem in your Rails 5 app's Gemfile. It's already merged into Rails 5.

Reference

4
  • rails-api g scaffold user email:string password:string auth_token:string and ommit gem 'rails-api' Gem file look like source 'rubygems.org' gem 'rails', '>= 5.0.0.beta3', '< 5.1' gem 'spring', :group => :development gem 'mysql2' and shoes the error: /.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:2157:in method_missing': undefined method this' for #<Gem::Specification:0xac89b0 rails-api-0.4.0> (NoMethodError)
    – Ahsan
    Apr 13, 2016 at 12:29
  • I also run bundle update, bundle install and the above error
    – Ahsan
    Apr 13, 2016 at 12:32
  • Remove gem 'rails-api' line from your Gemfile, and run bundle. It should be okay. Apr 13, 2016 at 12:35
  • I did, remove the gem 'rails-api' line from my Gemfile and run bundle update, bundle install and also shows the error: /.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:2157:in method_missing': undefined method this' for #<Gem::Specification:0xac89b0 rails-api-0.4.0> (NoMethodError) from /home/ahsanul/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:1056:in `find_active_stub_by_path'
    – Ahsan
    Apr 13, 2016 at 12:45
0

I tried all the above suggestion from Babar but didn't work, so i tried one little thing that work which is adding gem 'listen' to the gem file. it works for me!!

0
rails-api generate scaffold user email:string password:string auth_token:string

No need of writing rails-api, just use rails. Rails::API has been merged into Rails 5.0, so no need of gem 'rails-api'.So remove it from gemfile.After than you may get error when you try to migrate.So you have to include listen gem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.