Trying to run the following using Rails 3.2.2, switched to 3.2.1 and tried another machine to see if it was more core / OS related.
I try:
rails g bootstrap:themed events
I get:
.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.1/lib/active_support/inflector/methods.rb:229:in `const_defined?': wrong constant name event (NameError)
from /Users/charleyhine/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.1/lib/active_support/inflector/methods.rb:229:in `block in constantize'
from /Users/charleyhine/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.1/lib/active_support/inflector/methods.rb:228:in `each'
from /Users/charleyhine/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.1/lib/active_support/inflector/methods.rb:228:in `constantize'
from /Users/charleyhine/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.1/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
from /Users/charleyhine/.rvm/gems/ruby-1.9.3-p0/gems/twitter-bootstrap-rails-2.0.4/lib/generators/bootstrap/themed/themed_generator.rb:58:in `columns'
from (erb):6:in `template'
No need to downgrade the gem version. Instead, just change:
rails g bootstrap:themed events
to:
rails g bootstrap:themed Events
You need to capitalize and pluralize the model name, which is dumb, but it works
I was getting the same error. After searching for similar errors - I figured it must be a problem with the latest version of bootstrap, as I was not getting this error earlier.
I got the error with the version 2.0.4. The following line in the Gemfile followed by "bundle install" solved it for me.
gem 'twitter-bootstrap-rails', '2.0.2'
Related
Ok I'm not a pro at creating gems, but I tried my best and created this gem https://rubygems.org/gems/webpack_native/versions/0.2.0
This gem has generators and if I use it from the local folder (meaning the gem folder is in my computer) it works fine, if I type rails g in terminal it shows me the generators including my gem's generators
But using it from rubygems always give me an error uninitialized constant WebpackNative:
/home/mody/.rvm/gems/ruby-2.7.0#myapp/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/active_support.rb:80:in `block in load_missing_constant': uninitialized constant WebpackNative (NameError)
any thoughts on this?
I'm not sure how this happen but I get it to work after I installed devise gem and run
rails g
the output of the available generators shows up including my gem, and the generator itself is working.
So it's been a while since I fired up the old Rails server. It took a lot of tricks to even get the bundle to install... but eventually I upgraded from Rails 4.2.6 to 4.2.9. The bundle installs just fine. I'm on Ruby 2.3.0. But now the problem is... whenever I try to run:
rails s
I get the following error:
rails-html-sanitizer.rb:2:in `require': cannot load such file -- loofah (LoadError)
from /home/rainless/.rvm/gems/ruby-2.3.0#rails3.2.16/gems/rails-html-sanitizer-1.0.3/lib/rails-html-sanitizer.rb:2:in `<top (required)>'
from /home/rainless/.rvm/gems/ruby-2.3.0#global/gems/bundler-1.7.9/lib/bundler/runtime.rb:76:in `require'
from /home/rainless/.rvm/gems/ruby-2.3.0#global/gems/bundler-1.7.9/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/rainless/.rvm/gems/ruby-2.3.0#global/gems/bundler-1.7.9/lib/bundler/runtime.rb:72:in `each'
Or some variation of that.
At first I was getting around this by uninstalling whatever the Gem that was said to be unable to load (in this case "loofah" but I've done it with many more), and then adding it to the Gemfile and installing it using Bundler. I now realize that the list is never-ending:
gem 'rails-html-sanitizer'
gem 'chronic'
gem 'multipart-post'
gem 'oauth-active-resource'
gem 'rack-test'
gem 'multi_json'
gem 'addressable'
gem 'orm_adapter'
All the above couldn't load. I ran Rails for years before this... and I know this isn't the way it's supposed to work. Any help/advice on what could be going wrong?
If you see carefully in the error message, it says ruby-2.3.0#rails3.2.16 but you mentioned "upgraded from Rails 4.2.6 to 4.2.9." . For some reason, it's still referring to rails3.2.16. Therefore it could be you need to install the rails-html-sanitizer globally. By the way, Loofah is only needed if you wanted to use it in a non-rails app. Refer to the docs here.
Rails Html Sanitizer is only intended to be used with Rails
applications. If you need similar functionality in non Rails apps
consider using Loofah directly (that's what handles sanitization under
the hood).
from /home/rainless/.rvm/gems/ruby-2.3.0#rails3.2.16/gems/rails-html-sanitizer-1.0.3/lib/rails-html-sanitizer.rb:2:in `<top (required)>'
I'm very new to Rails, and I'm trying to build a user authentication system with 'devise', but I am failing. I'm following Rails Girls Guides's tutorial on adding authentication using the gem 'devise'. Once I got to step 5, which is to set up the User model, I received this error after running rake db:migrate
rake aborted!
NoMethodError: undefined method `merge!' for #<ActionDispatch::Routing::Mapper::Scope:0x007fd3397a7448>
/Users/.rvm/gems/ruby-2.1.2/gems/devise-3.0.4/lib/devise/rails/routes.rb:420:in `ensure in with_devise_exclusive_scope'
/Users/.rvm/gems/ruby-2.1.2/gems/devise-3.0.4/lib/devise/rails/routes.rb:420:in `with_devise_exclusive_scope'
/Users/.rvm/gems/ruby-2.1.2/gems/devise-3.0.4/lib/devise/rails/routes.rb:233:in `block (2 levels) in devise_for'
/Users/.rvm/gems/ruby-2.1.2/gems/devise-3.0.4/lib/devise/rails/routes.rb:336:in `block in devise_scope'
Has anyone solved this error? I've looked at all solutions such as not generating user model before installing devise, running bundle install, running rails g devise:install, and more. Nothing has worked so far when I'm trying to use devise for Rails 4.0.
Also, does anyone have recommendations on what tutorials I can follow to build an authentication system? I've tried a lot so far, and none has worked.
This looks to be a know bug with prior 3.4.0 devise.
Upgrading it should make this error go away.
To do that edit your Gemfile where you have gem "devise" <might have some other stuff in front> and change it to gem "devise", '~> 3.4.1'
then run bundle update devise and you are done.
I'm trying to get Devise up and running. I'm using devise 1.0.10 and rails 2.3.8, on an otherwise pretty clean hostingrails install.
When I run ruby script/generate devise_install
I get the following error message. Has anyone seen this before. Any ideas how to proceed with the install? I searched around and hit a wall.
Thanks, Tim
ruby script/generate devise_install
/home/p7017r10/appname/config/environment.rb:4: warning: already initialized constant RAILS_ENV
/usr/local/rvm/gems/ruby-1.8.6-p369/gems/activerecord-2.3.8/lib/active_record/base.rb:1994:in method_missing': undefined local variable or methodauthentication_keys' for # (NameError)
from /usr/local/rvm/gems/ruby-1.8.6-p369/gems/devise-1.0.5/lib/devise/models/validatable.rb:18:in included'
from /usr/local/rvm/gems/ruby-1.8.6-p369/gems/devise-1.0.5/lib/devise/models/validatable.rb:16:inclass_eval'
from /usr/local/rvm/gems/ruby-1.8.6-p369/gems/devise-1.0.5/lib/devise/models/validatable.rb:16:in included'
from /usr/local/rvm/gems/ruby-1.8.6-p369/gems/devise-1.0.5/lib/devise/models.rb:66:ininclude'
from /usr/local/rvm/gems/ruby-1.8.6-p369/gems/devise-1.0.5/lib/devise/models.rb:66:in devise'
from /usr/local/rvm/gems/ruby-1.8.6-p369/gems/devise-1.0.5/lib/devise/models.rb:65:ineach'
from /usr/local/rvm/gems/ruby-1.8.6-p369/gems/devise-1.0.5/lib/devise/models.rb:65:in devise'
from /usr/local/rvm/gems/ruby-1.8.6-p369/gems/devise-1.0.5/lib/devise/orm/active_record.rb:24:inincluded_modules_hook'
... 37 levels...
from /usr/local/rvm/gems/ruby-1.8.6-p369/gems/rails-2.3.8/lib/commands/generate.rb:1
from /usr/local/rvm/rubies/ruby-1.8.6-p369/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require'
from /usr/local/rvm/rubies/ruby-1.8.6-p369/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from script/generate:3
check the devise group on google groups
http://groups.google.com/group/plataformatec-devise
that's the better forum to ask this question
I guess you should look into initializers/devise.rb. There are some instructions on setting those keys. Plus, please refer to http://asciicasts.com/episodes/210-customizing-devise, http://blog.plataformatec.com.br/tag/subdomain/.
I didn't use devise with RoR 2.3.x, only with 3.0.x. That could be the difference.
Hope that helps. Let us know :)
I upgraded my rails 2.3.8 app to rails 3. when I run the rake db:reset command, it returns the following error
rake aborted!
test-unit is not part of the bundle. Add it to Gemfile.
/Users/Shenario/Desktop/stack24/Rakefile:7:in `'
(See full trace by running task with --trace)
i'm new to rails, and wud be glad if you guys out ther coud help me! thanks!
the trace --
rake aborted!
test-unit is not part of the bundle. Add it to Gemfile.
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.7/lib/bundler/shared_helpers.rb:102:in block in cripple_rubygems'
/Users/Shenario/Desktop/stack24/lib/tasks/rspec.rake:1:in'
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/engine.rb:131:in load'
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/engine.rb:131:inblock in load_tasks'
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/engine.rb:131:in each'
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/engine.rb:131:inload_tasks'
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application.rb:141:in load_tasks'
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application.rb:77:inmethod_missing'
/Users/Shenario/Desktop/stack24/Rakefile:7:in <top (required)>'
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/gems/rake-0.8.7/lib/rake.rb:2383:inload'
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/gems/rake-0.8.7/lib/rake.rb:2383:in raw_load_rakefile'
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/gems/rake-0.8.7/lib/rake.rb:2017:inblock in load_rakefile'
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling'
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/gems/rake-0.8.7/lib/rake.rb:2016:inload_rakefile'
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/gems/rake-0.8.7/lib/rake.rb:2000:in block in run'
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling'
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/gems/rake-0.8.7/lib/rake.rb:1998:in run'
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/gems/rake-0.8.7/bin/rake:31:in'
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/bin/rake:19:in load'
/Users/Shenario/.rvm/gems/ruby-1.9.2-p136/bin/rake:19:in'
After searching for "test-unit", found this:
gem 'test-unit', '2.0.7' if RUBY_VERSION.to_f >= 1.9
in lib/tasks/rspec.rake
I suspected it was caused by me copying the whole lib folder from older rails version to this new one.
Solution: removed that file, then things seem to work fine after.
Basically I suggest you look at lib/tasks and see if there are rake tasks that are incompatible with rails 3.
you must have at least
gem "rails", "~> 3.0.3"
in your Gemfile, then remove Gemfile.lock (if any) and run:
bundle check
if you need some missing gems, run:
bundle install
bundler will install all required gems at least for rails 3.0.3, including test-unit gem. btw remember that a migration from rails 2.3.x to 3.0.x in most cases requires some code changes.
Add this to your Gemfile (replacing VERSION with your required version number).
gem 'test-unit', 'VERSION', :platform => :ruby_19
For Rails 2.3.11, I needed version 1.2.3 of the test-unit gem.