I'm creating a Rails plugin which uses Mobility gem.
I can see the installer listed when I do
rails generate --help
But then if I run
rails generate mobility:install
I get this totally weird error:
Could not find generator 'mobility:install'. Maybe you meant 'mobility:install', 'binda:install' or 'devise:install'
My guess is that mobility generator isn't located in lib/generators/mobility but in lib/generators/rails/mobility. See the github repository. The issue does appear only on Rails plugin not on Rails application.
Any idea how to overcome this issue?
As you suspected, the problem is the paths used for generators in Mobility. This PR will fix the issue.
Related
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.
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.
I'm attempting to create a new Rails 3 plugin gem which wraps around devise/devise_ldap_authenticatable for reusable drop in internal LDAP support.
I create the new plugin gem with:
rails plugin new <gem_name>
I then add the devise/devise_ldap_authenticatable gems to the .gemspec file and run bundle
In the devise instructions it says to generate the required files using its generators:
rails generate devise:install
rails generate devise MODEL
However, in the directory where the plugin is generated I don't seem to be able to run rails generate. Most gem plugin tutorials instruct you to just create the files manually. Am I better off starting a new rails project, following the instructions in the temp project, then copying the files over to the plugin manually? Is there something that I'm missing? Can I run the generator script from the dummy instance? What is the standard practice in this use case?
In the end, I opted to forgo wrapping devise_ldap_authenticatable due to its relative simplicity.
The answer that I would go with in the future is to just to move files from a throwaway project.
Does the acts-as-readable plugin work for rails 3? The instructions at https://github.com/mbleigh/acts-as-readable results in Plugin not found: ["http://svn.intridea.com/svn/public/acts_as_readable"]
Downloading the source from github and sticking it in vendor/plugin doesn't seem to work, I get: Could not find generator acts_as_readable_migration.
I am doing something wrong or should I look elsewhere?
I forked the plugin to my GitHub account and updated its generators to work with Rails 3, which can be found at https://github.com/tjackiw/acts-as-readable.
After you install it
rails plugin install git://github.com/tjackiw/acts-as-readable.git
then you can do
rails generate acts_as_readable_migration
Have fun!
try script/rails plugin install git://github.com/mbleigh/acts-as-readable.git to install it from that git repo.
Looks like it will install, but uncertain if it "works" given it hasn't been updated since 2008
I recently created a project skeleton with Edge Rails and installed rspec, rspec-rails and cucumber as plugins (git submodules). If I run:
$ script/generate
all I get is a list of built-in generators. The ones from the plugins don't show up. I installed the same plugins as gems and got the same result. Does anyone know why this is happening and/or how I can fix it?
Your best best is probably to create an issue on the Rails ticket system - http://rails.lighthouseapp.com. It will get seen by the right people there.