Kaminari gem doesn't seem to install - ruby-on-rails

I added "gem 'kaminari'" to my gemfile and ran bundle per the instructions, and it looked like it installed, but I'm getting errors like 'current_page' method not found messages. The documentation indicates that there should be a kaminari directory created in my app/views directory, but there isn't one. I'm using rails 3.0.7. Is there a different/better way of installing this gem?
Thanks

Could you have forgotten to run the generator?
rails g kaminari:views default
That should create your kaminari directory.

Related

Spree category pages in custom rails app

I have created a default rails app. I am beginner to spree.
I am not able to find the code for the pages which are coming by default in the spree app.
This is how I have created the app
gem install rails -v 4.2.2
gem install bundler
gem install spree_cmd
rails _4.2.2_ new mystore
cd mystore
spree install --auto-accept
When I go to http://localhost:3000/t/categories/bags I get all the categories for this category.
But in my view I do not see any code. So from where are these coming from?
Please help.
it is coming from spree gems, you can see the front end code by opening the gem file in your editor by following. (you need to set you environment variables EDITOR or BUNDLER_EDITOR)
bundle open spree_frontend
or else you can do in terminal
bundle show spree_frontend
open 'path above something like /Users/xyz/.rvm/gems/ruby-2.2.3/gems/spree_frontend-3.0.8'
These pages come from within the Spree gem, which adds routes and views. Have a poke around and see what you find here: https://github.com/spree/spree/tree/master/core/app
It runs as a Rails engine, so read up on how that works here if you want to know how the gem adds routes: http://guides.rubyonrails.org/engines.html
See rails request/response log to find the rendered partials path in a request.
Also you may find http://guides.spreecommerce.com/developer/view.html helpful.

Geokit issue - "could not find generator"

I am trying to get started with Geokit, and I ran the install command and was greeted with the following:
rails g geokit_rails:install
Could not find generator geokit_rails:install.
Any idea what's going on? I am so confused. bundle install works just fine. I run bundle exec rake db:migrate. but when I go into the console, when I try require 'geokit', I get false. I assume it's because the config file is missing? But how do I generate a sample config file to modify if the install script is failing??
The problem is that your version of the geokit-rails gem does not contain the generator. It was added with https://github.com/geokit/geokit-rails/commit/bb4261acef62a26de823c4b7306634ffb7c3381f. The latest version of the gem is 2.1.0, and as you can see here, the generators were not part of that release.
If you want to use the head version of the gem, then you can change your Gemfile to match gem 'geokit-rails', github: 'geokit/geokit-rails'.

How do I remove a gem with all its dependencies? [duplicate]

I have installed a gem on my Rails application (devise). After I installed the gem, I realized that I don't need it.
I want to remove the gem, its dependencies and the files it created on my application. In other words, I want to restore the system to what it used to be before the gem. How can I do this? (I'm using Ruby on Rails 3.)
You can use
gem uninstall <gem-name>
If you're using Rails 3+, remove the gem from the Gemfile and run bundle install.
If you're using Rails 2, hopefully you've put the declaration in config/environment.rb. If so, removing it from there and running rake gems:install should do the trick.
Devise uses some generators to generate views and stuff it needs into your application. If you have run this generator, you can easily undo it with
rails destroy <name_of_generator>
The uninstallation of the gem works as described in the other posts.
For Rails 4 - remove the gem name from Gemfile and then run bundle install in your terminal. Also restart the server afterwards.
How about something like:
gem dependency devise --pipe | cut -d \ -f 1 | xargs gem uninstall -a
(this assumes that you're not using bundler - but I guess you're not since removing from your bundle gemspec would solve the problem)
You are using some sort of revision control, right? Then it should be quite simple to restore to the commit before you added the gem, or revert the one where you added it if you have several revisions after that you wish to keep.

why nifty_generators not being recognized?

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.

How do you create a rails migration generator in a ruby gem?

Im creating a simple Rails 2.3.8 gem and need a migration file inside it. I following this structure:
/
/generators
/generators/conductor_migration
/generators/conductor_migration/conductor_migration_generator.rb
/generators/conductor_migration/templates
/generators/conductor_migration/templates/conductor_migration.rb
but when I install the gem in my app and run script/generate conductor_migration i says it cant find the migration.
Any thoughts?
Turns out it's a bug in bundler for 2.3.8. I received a note from them yesterday saying that you can't access generators in gems that are local with bundler in 2.3.X you need to install them from the server. Lovely.

Resources