How to add dependencies to Rails engine's dummy app? - ruby-on-rails

I would like to add a few dependencies in my test/dummy app so that I can do integration test of my engine. I added a test/dummy/Gemfile and put the dependencies on it:
gem 'devise'
gem 'devise_invitable'
after I run bundle install inside the test/dummy, the test/dummy/Gemfile.lock is created.
but when I run rails g devise:install inside the test/dummy, it says
method_missing': undefined method `active_storage' for #<Rails::Application::Configuration:0x00007fad8f2a0dc0> (NoMethodError)
How am I able to add dependencies to the dummy app?
The only way I can get it to work is if I add it to the dependencies of my engine gem. but I prefer not to do that
EDIT: I added rails in my Gemfile and devise install can be run, but after I run my test, it has this error:
test/dummy/config/initializers/devise.rb:11:in `<top (required)>': uninitialized constant Devise (NameError)

Related

ruby gem issue uninitialized constant

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.

Undefined method 'register_engine' while trying to install Ember to Rails

I started learning Ember.js using Rails as back-end, and created a test project. So, first I removed turbolinks from app and added the following gems to Gemfile:
gem 'ember-rails'
gem 'ember-source', '~> 1.8.1'
gem 'emblem-rails'
and bundled them. Next, I ran
$ rails g ember:bootstrap -n App --javascript-engine js
and it has returned me the following error:
/home/alex/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/emblem-rails-0.2.2/lib/emblem/rails/engine.rb:7:in
`block in <class:Engine>':
undefined method `register_engine' for nil:NilClass (NoMethodError)
Is the problem that something can be deprecated? I'm following the tutorial written in 2014.
The trouble was caused by emblem-rails gem - I commented it out, and everything worked

undefined method rails 3.2.9 and devise 1.0.11

Error:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/devise-1.0.11/lib/devise.rb:89:in '': undefined method 'weeks' for 2:Fixnum (NoMethodError)
That error is thrown whenever I try to run 'rails g devise:install' in a rails project I've been working on.
Any ideas?
P.S. requiring gem 'devise' in Gemfile and running bundle install to get the devise gem
This issue was already dealt with here. Try updating to a later devise version to fix.

How to implement twitter-text-rb

Hi I am trying use twitter-text-rb gem.
added "include Twitter::Autolink" in application helper follow by example, after restarting the server getting error
Routing Error
uninitialized constant Twitter::Autolink
Add this to your Gemfile:
gem 'twitter-text'
And then run:
bundle install

ruby on rails rspec error

I'm following through the "Learn Rails by Example" book, and I'm trying to run the tests. For some reason I can't get rspec to work properly.
If I run the rspec spec/ command as he instructs, I get the following error:
$ rspec spec/
/home/desktop/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.21/lib/bundler/runtime.rb:31:in `block in setup':
You have already activated rspec-core 2.7.1, but your Gemfile requires rspec-core 2.6.4.
Using bundle exec may solve this. (Gem::LoadError)
The odd thing is my Gemfile doesn't specify version--
group :development do
gem 'rspec-rails'
end
group :test do
gem 'rspec'
gem 'webrat'
end
If I follow the advice from the error message and use bundle exec rspec spec/ then the first two tests pass-- but the new "about" page we built in the tutorial fails with the following error, even though as far as I can tell the page I'd built (and controller actions etc.) are exactly as they should be:
Failures:
1) PagesController GET 'about' should be successful
Failure/Error: response.should_be_success
NoMethodError:
undefined method `should_be_success' for #<ActionController::TestResponse:0x00000003539438>
# ./spec/controllers/pages_controller_spec.rb:23:in `block (3 levels) in <top (required)>'
Finished in 0.10861 seconds
3 examples, 1 failure
Failed examples:
rspec ./spec/controllers/pages_controller_spec.rb:21 # PagesController GET 'about' should be successful
I'm a pretty experienced programmer but I've run into endless issues with conflicting gem versions and a hundred different ways to accomplish all the different tasks using Rails (eg. "use RVM", "Don't use RVM", "install gems using sudo", "don't install gems using sudo" etc.)
My dev machine is running ubuntu linux.
Thanks for any help-- please explain if you would what I'm doing wrong in Ruby noob language!
Running bundle exec is correct, and is needed because you have a newer version of that gem installed that gets loaded instead of the one specified in your Gemfile.lock. Using bundle exec overrides the load path, causing only the gems specified in your Gemfile.lock to be loaded. (You may find it handy to alias bundle exec to something shorter.)
The answer to the second problem is right in the error messages:
undefined method `should_be_success'
it should be should be_success.

Resources