why nifty_generators not being recognized? - ruby-on-rails

i have installed nifty_generators successfully. Though, when i run the following command:
rails generate nifty_authentication
i get the error:
Could not find generator nifty_authentication.
I have included gem 'nifty_generators' in my gem file. What is the error?

Couple of things after looking on its github.
First, I believe the gem is call nifty-generators not nifty_generators, which may be causing you some other problems as well.
Second, per the instructions , you should be calling it via rails g nifty:authentication.

Related

Vanity gem: strange rails generate vanity error

I'm trying to introduce the Vanity gem into a project and everything is happy right up until I try to run the generator. This is the call:
rails generate vanity
And this is the output:
Could not find generator 'vanity'. Maybe you meant 'vanity', 'task' or
'mailer'
Run rails generate --help for more options.
Notice that it can't find 'vanity' and then suggests vanity. Wut? I then took a moment to verify that the generator actually exists:
rails generate --help | grep "anity"
and got:
Vanity:
vanity
vanity:views
I am using Spring, so I stopped that with spring stop.
I should also note that I tried a bunch of things like:
rails generate Vanity:vanity
rails generate vanity:vanity
rails generate Vanity
rails generate oh:please:do:vanity
Additionally, I am actually using bundler so I tried ALL these things with and without bundle exec at the beginning of the commands.
I wonder if perhaps this error is actually masking an issue in my local setup, but I've looked really closely and am convinced that the installation and setup of vanity is correct.
Version information:
ruby 2.5.5p157
Rails 5.2.3
Vanity 3.0.0
EDIT: additional information: I went down the path of stopping the Spring server, bundle update and then trying the generator--nothing changed. I've even tried going into the actual generator and debugging there. While it loads the file, it never executes any of the methods.
Solved this on my own. It turns out that the vanity gem wasn't automatically pulling the generators into the load path. That means that when the generator was called, it was erroring out because it couldn't find the actual generator class in the first place.
The generator error was masking that error and making it look like the generator itself couldn't be found.
The fix for this was to explicitly require the generators in a config/initializers/vanity.rb file.
The vanity gem claims that in Rails apps the classes are "automagically" available.

Rails Generate model error in Ruby on Rails

I am building a new RoR app and i had tried to create a new model like below.
rails generate model Pic title:string description:text
But I keep on getting these errors always and I tried installing many methods like installing gems ,updated the gems etc.
P.S : I am trying install the older version of the gems. Is that creating a problem?
But none of it gave me the results. Please help me with this.
P.P.S : I am an absolute beginner to ruby. So please help me by giving solution with good reason. Thanks in Advance.
Hi seems like you have issues with your simple_form gem,try to remove from gem file and add gem 'simple_form' and run bundle install after this step run rails generate simple_form:install for creating config file for simple form.
Try this it may help you out.
As #Navneet pointed out generating a config file can also be used for configuration and it also works pretty well.
Another thing i found was , Here the gems used were older version. That created a compatibility issue(since it was not configured accordingly). So by replacing the gems with current version or stable ones , you can get rid of this problem.
Go to rubygems.org
Search for the gems and check whether its the latest version
If not, Replace the line of corresponding gem in Gemfile with newest one.

Simple Captcha Error

I am trying to use the simple-captcha gem with
gem "galetahub-simple_captcha", :require => "simple_captcha".
I am running Rails 5.0.0.1 and Ruby 2.3.2.
I couldn't get it to work in my app so I created a clean skin, rails new, rails generate scaffold User, rake db:migrate etc. As soon as I add the gem, I can bundle install fine, but as soon as I run rails test or rails generate or anything I get this error:
user/.rvm/gems/ruby-2.3.3/gems/galetahub-simple_captcha-0.1.5/lib/simple_captcha/form_builder.rb:7:in `included': uninitialized constant Sprockets::Helpers (NameError)
I have tried following the setup instructions for the gem, which says to run rails generate captcha after installing the gem, but as soon as I have installed the gem I get the error.
Any help would be appreciated.
On the other hand if anyone thinks there is a better captcha I should be using for form submission, let me know.
Looks like latest commit to "simple_captcha" repository was 3 years ago. It's outdated and maybe it will be not worked with Rails 5.
You can use Recaptcha from Google https://github.com/ambethia/recaptcha
You can use Recaptcha gem as advised by Alex
There is nice tutorial for this https://www.sitepoint.com/quick-tip-add-recaptcha-to-your-rails-application/
What happens after the simple captcha is installed?

Ruby on Rails - doesn't recognise gem - installation issue?

I'm just trying to build an app on rails to do a simple search on flickr. Unfortunately, before I can do anything remotely interesting, it doesn't seem to recognise the 'flickr' gem I installed. As a simple test, all I did was to generate a controller called flickr with a method called flickrsearch. In that method, all I put in there is
require 'flickr'
but in the browser, I have the following error:
cannot load such file -- flickr
In fact, I originally wanted to require 'flickr' in config/environment.rb but the server wouldn't even fire up. It gave me errors saying it couldn't load flickr. I've tried it with other installed gems as well but same result.
A month ago when I first played around with Ruby, I installed Ruby and some gems as well. Everything worked fine...but recently, I installed Rails using Railsinstaller on http://railsinstaller.org/ (I use Windows 7). So I'm guessing it's looking in the wrong place for gems.
So it looks like I originally had gems in c:\Ruby193 and now I also have gems in c:\RailsInstaller\Ruby1.9.3
So...I decided to delete the whole c:\Ruby193 in a moment of madness...I know, probably not the cleanest way to do it.
Then reinstalled the flickr gem (gem install flickr). This time, it actually create the gem files for flickr in c:\RailsInstaller\Ruby1.9.3. Which is what I expected but I'm still having the problem of Rails not recognising the flickr gem.
Please help...Many thanks.
Sam
You should not have to explicitly require gems in Rails. Just make sure you've added the flickr gem to your Gemfile and you've run the bundle install command.

spree commerce in Rails

I am newbie to Ruby on Rails and I would like to install "Spreecommerce". Could I have some help on doing this? I don't know where to start. Any help will be highly appreciable, thanks!
You are talking about Spreecommerce. Next time, try to add a link to the project/gem/plugin you are talking about.
Install the gem, on the command line like this:
gem install spree
Or, go to the Gemfile of your project and add the following line:
gem 'spree'
Then type this in the command line:
bundle install
Then, go to the official github page and read the documentation of this gem to get more information about it and how to use it. There is also this official getting started page that you need to read.

Resources