简体   繁体   中英

uninitialized constant Formtastic::SemanticFormBuilder (NameError) when starting rails server

I was trying to start my rails server, but I am getting the following error:

/config/initializers/formtastic.rb:27:in `': uninitialized constant Formtastic::SemanticFormBuilder (NameError)

The only thing I can remember what I did last was a bundle install, and since then it hasn't been working. I have tried removing and reinstalling my gems, even the formtastic gem. When I do remove the formtastic gem from my gemfile i get the following error:

/config/initializers/formtastic.rb:27:in `': uninitialized constant Formtastic (NameError)

I then went to comment that formtastic.rb to see what is going on, and when I tried to start the server I then got another error, from another one of my files:

/app/api/V1/base_api.rb:11:in inherited': undefined method inherit' for API::V1::ShoppingListAPI:Class (NoMethodError)

Whatever I do, another name error comes up. Not sure what is going on and how to debug this. I have tried to search the internet and have found no solutions to this. Wondering if someone has uncovered the same problem.

Nope, that's not the problem. SemanticFormBuilder has been renamed to FormBuilder as of version 2.

If you create formatastic.rb in your initializers you got this error if you don't need that file remove it and run.
The path is:

Configuration/Initializers/formtastic.rb

This seems a Gem dependency problem. When you did "bundle install" you've probably installed another Gem version you used earlier.

I highly recommend you to use RVM and create Gemsets to avoid and prevent Gem dependency issues: https://rvm.io/

Also you may want to check out your Gemfile and Gemfile.lock to see how they works (checkout Railscasts for more info). I think removing that Gem is not a really good idea, probably better if you reinstall it. Also removing that file isn't really helpful. Try to solve this with RVM and installing right gems and you'll be good to go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM