error when running rails g cancan:ability - ruby-on-rails

I added the gem cancancan, ~> 1.10 to my gemfile and then ran bundle install.
That all went well but then I get the following in my terminal when I run > rails g cancan:ability:
Running via Spring preloader in process 967 Could not find generator 'cancan:ability'. Maybe you meant 'coffee:assets', 'channel' or 'css:assets' Run rails generate --help for more options.
I tried running the command spring stop and then ran rails g cancan:ability and I get the same message.
Any ideas? Thanks for the help.

Related

Spring is troubling rails console to start

When i am trying to execute:
bundle exec rails console
It is throwing me error as:
/gems/spring-3.1.1/lib/spring/application.rb:96:in `preload': Spring only supports Rails >= 5.2.0 (RuntimeError)
Earlier it was working fine.
Can anyone help me with a workaround for this.
The workaround I did for this was to create a new project with rails 5.2.3 or something.
If you want to do the same, you can first list all your local gems by doing gem list rails --local
You will see all your rails versions installed locally.
Then do gem install rails -v '5.2.3'
Now go to a new project directory and run rails _5.2.3_ new appname
Now, you should be able to use the console, generate, migrate and other commands.
You can do bundle install after adding other relevant gems based on your apps requirement.

rails console not working 'bundle exec rails c' on kubernetes

I am trying to run rails console using bundle exec rails c command. But console is not opening. I have not installed ruby or rails using apt, instead using rvm and gems respectively.
But when i ctr + c to terminate command i get some error as below
/mypath/vendor/bundle/ruby/2.6.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:90:in
connect: Interrupt
I am not able to understand exact error.

dynamic_form gem causes console not to load. Rails 4

I installed 'dynamic_form' gem in my rails 4.1.4 app. When I tried to run console (bundle exec rails console) I get the error below:
$ bundle exec rails console
Could not find dynamic_form-1.1.4 in any of the sources
Run `bundle install` to install missing gems.
But when I run server (bundle exec rails server) seems to work just fine.
Anyone else encountered this issue? thanks!
If you're talking about this gem, it looks to be significantly outdated. I doubt it has official Rails 4 support. Someone actually submitted an issue asking if Rails 4 support will be added.
Consider using another form gem - there are plenty.

'rails s' throwing error

I am configuring a Rails APP. I did bundle install properly. Also using ruby 1.8.7 using RVM. Now after bundle install, it is throwing the below given error while doing rails s.
/usr/local/lib/site_ruby/1.8/rubygems.rb:335:in `bin_path': can't find
executable rails for rails-3.2.9 (Gem::Exception)
Can anyone help me to sort out this?
Using ruby: 1.8.7
Rails Version: 3.0.3
After running bundle install, your Gemfile.lock has a list of all the gems and their versions that are needed.
However, you need to run bundle exec in order for bundler to make those gem versions available to you.
The rails script is an exception, as it invokes bundler for you, but it sounds like something isn't working in your environment.
Try executing the rails script using bundle exec like so:
bundle exec rails s
And see if that helps. Also, from the man who wrote bundler: http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/
You have two rails gem versions in same gemset so it is picking latest version. So you need to specify rails version for rails commands.
Try this:
$ rails _3.0.3_ server

Unable to start Rails server

The issue is when I try to start server with rails server command after successfully created Rails app by running rails new myapp -d=mysql. However, I cant get the server to start and it gives me the following error:
Could not find gem 'mysql2 (~> 0.2.6, runtime)' in any of the gem sources listed in your Gemfile. Run `bundle install` to install missing gems.
Then I run bundle install but could not happen.
I have installed:
Ruby 1.8.7
Rails 3.0.9 with mysql
RubyGems 1.8.7
I searched everywhere but nobody can solve my problem please help me with this issue as soon as possible. I am using Ubuntu 11.04.
Thanks in advance.
If your bundle install is saying everything is installed, try prefixing your rails command with
bundle exec rails server <other args here>
That will make sure you run the server in the context of the bundle (as defined by your Gemfile). If that fixes the problem for you, then you can either keep running the server using that command, or figure out what's wrong with your environment (might be a path issue, or you might have multiple versions of ruby or bundler installed and things aren't getting installed where you think they are)
i have reinstalled rails 4.2.4 using "gem install rails" command
and generated new project using rails new helloworld
"cd helloworld" and "rails server" would started my server.

Resources