Update ruby gem version with new changings - ruby-on-rails

I have developed a gem for learning purposes and push it to https://rubygems.org/gems/combination-pairs. Now I want to do some changes in the code of the gem. Means I want to update my same gem but with different version. How can we do the same??

Follow these steps to update your ruby gem with changes:
Keep testing your code and make the required changes in your gem code (locally)
Once you are done with Step 1, update the version of your gem in lib/combination/pairs/ version.rb file by following the Semantic Versioning Guidelines. Let's say you change the version of your gem to 0.0.2
Next, run bundle install command in your gem's working directory to install all the gem dependencies.
And finally, run the task rake release which will create tag v0.1.2 and build and push combination-pairs-0.0.2.gem to Rubygems. This task is available to you as I see that you have the following line in the Rakefile
require "bundler/gem_tasks"
You can double check the list of available rake tasks by executing the command
rake -T
NOTE:
Just for your reference, check out this awesome Railscasts by Ryan Bates: New Gem with Bundler

Related

gem development (not load other Gemfile)

I've an issue with gem file development, for example I'm creating a gem with executable command.
It all works well, I can run command, BUT I've issue that if I'm trying to run command inside another project folder it's USING Gemfile from this second project.
Can I somehow disable it?
I want only to use Gemfile (and .gemspec) from my gem, and not with folder where it was executed.
I have a gem github.com/igorkasyanchuk/rails_db (version in master branch is not released yet, so you need to build it locally), gem build ..., then gem install ..., and then go to your project dir and run "railsdb". When you run it, it's trying to load gems from local folder Gemfile.
Thanks
Igor
If you are using the rubygems-bundler gem, executing commands provided by a gem will load the bundle of your current directory. You can prohibit this from happening for a particular gem providing commands in various ways. One way:
export NOEXEC_EXCLUDE=my_gem_command
See https://github.com/rvm/rubygems-bundler for more information about rubygems-bundler.

Could not find request_store-1.0.6 in any of sources

I am new to ruby. I am trying to use AuthLogic gem in my rails application. I had installed it and added
config.gem"authlogic"
in my environment.rb file and executed the command
rails generate nifty_scaffold user username:string email:stringpassword:string new
It thrown me a error "git://github.com/odorcicd/authlogic.git (at rails3) is not yet checked out. Run bundle install first." Oftenly even though i run bundle install. Why? Please any one help me.
If you are using Rails 4+ versions, you need not to include gems in environment.rb file. You should add the gems in Gemfile as follows,
gem 'authlogic'
Once you have added new gems in Gemfile in addition to the existing gems, you must run
bundle install
so that, your rails application can consider including the recently added gems (here, authlogic gem in our example) in your application. That is what the reason why you need to run bundle install more often (only when you add new gems in Gemfile)
And, please do not add gems in config/environment.rb file. That is Rails 2 way.

How can I install different versions of Rails and keep the existing ones?

I had Rails 2.3.5 installed, and wanted to upgrade to 2.3.10 as a stepping stone to Rails 3. I thought running gem install rails -v=2.3.10 would install 2.3.10 and keep 2.3.5 as well. But now when I do rails -v, it only lists Rails 2.3.10. How can I install different versions of Rails and keep the existing ones?
gem list rails should show you all installed versions of Rails. You can specify which one you want each project to use in the config/environment.rb file.
Alternately (or "additionally"), look in to RVM (particularly the "gemset" function) for maintaining separate gem sets for each project.
Updated May 2017 Instead of RVM gemsets, best practice for managing gems in Rails projects (including the Rails gem itself) is to use Bundler. Bundler's Gemfile will list all the gems your project uses, and allows you to "pin" versions, so by changing the version pin for Rails and running bundle you can update your project to the new version.
<sarcasm>Now that I've said that, though, Bundler is probably on the way out to be replaced by something else. </sarcasm>
You still have both versions, as the other answers have mentioned. However, you don't want to call rails newapp and then change the config/environment.rb file. This will cause problems for any files that have changed between versions. Instead, create a new 2.3.5 app this way:
rails _2.3.5_ newapp
And you'll run the exact version of rails you want, to create the file structure correctly. I don't know why this isn't documented better.
To answer your question, you can install many versions of the rails gem without conflict. However, each project is created using a specific version. To install a new version of the rails gem as follow;
Change the version 3.2.18 with any version you like (see link below for all available versions).
gem install rails --version=3.2.18
To install the latest version
gem install rails
To check all the rails version available, check out this link
Here is a link to all the version of rails
You might consider updating your gem software by this command prior to loading new gems.
gem update --system
As per #pjmorse, list the version installed with this command
gem list rails
Hope that helps
You can define the Rails version of an application in config/enviroment.rb.
You can vendor the version of rails you want into your vendor/rails folder. At the command line just run rake `rake rails:freeze:edge RELEASE=2.2.2'. You don't need any version of rails installed for this to work it will take the source and build it from the remote source in your vendor directory.
rake rails:freeze:edge RELEASE=2.2.1
rake rails:freeze:edge RELEASE=2.2.2
rake rails:freeze:edge RELEASE=2.2.3
rake rails:freeze:edge RELEASE=2.2.4
rake rails:freeze:edge RELEASE=2.2.5
rake rails:freeze:edge RELEASE=2.2.6
rake rails:freeze:edge RELEASE=2.2.7
rake rails:freeze:edge RELEASE=2.2.8

How to install authlogic in Rails 3?

I find that the the config/environment.rb file looks different in Rails version 3.0.
Also when i add the line "config.gem "authlogic".To environment.rb file
For Rails 3, you no longer edit config/environment.rb. You edit Gemfile, adding
gem 'authlogic'
to it, and then do a
bundle install
more info: http://gembundler.com/rails3.html
There will be a Gemfile.lock, and it lists all the gems and their versions in your project. Bundler's docs:
Whenever your Gemfile.lock changes,
always check it in to version control.
It keeps a history of the exact
versions of all third-party code that
you used to successfully run your
application.
When your co-developers (or you on
another machine) check out your code,
it will come with the exact versions
of all the third-party code your
application used on the machine that
you last developed on (in the
Gemfile.lock). When they run
bundle install, bundler will find the
Gemfile.lock and skip the dependency
resolution step. Instead, it will
install all of the same gems that you
used on the original machine.
Pretty basic step by step tutorial here: http://www.logansbailey.com/2010/10/06/how-to-setup-authlogic-in-rails-3/

In Ruby on Rails, what's the difference between installing something as a gem or as a plugin?

On http://github.com/collectiveidea/delayed_job
it says:
To install as a gem, add the following to config/environment.rb:
config.gem 'delayed_job'
Run rake gems:install
versus
To install as a plugin:
script/plugin install git://github.com/collectiveidea/delayed_job.git
What is the difference between installing it as a gem or as a plugin?
Also, the first method just install gem 2.0.3 which might be the tobi's version? (rake gems:install installs the version by gem list -r delayed_job) Is it http://github.com/tobi/delayed_job ?
The "plugin" method specifically says it is the collectiveidea version? Doesn't it matter which one you install?
Both the Gem and the vendored plugin refers to the collectiveidea's fork. In fact, collectiveidea is the current maintainer for the delayed_job Gem on RubyGems.
That said, generally speaking installing a plugins as a Gem has many advantages.
You can install it once and use it in many different projects
You can take advantage of dependency resolution
You can upgrade just changing version number
You don't need to store the entire plugin code in your SCM
So, why you can install a plugin "as a plugin"?
There are many different answers.
At the very beginning, Rails plugins came as simple libraries. Time passes and developers started to notice the advantage of packaging plugins as Gem.
Also, before Rails 3, some plugin features were only reserved to plugins and not to Gems. For instance, before Rails 3, plugins could bundle rake tasks while there wasn't a way to inject new rake tasks or new routes into the main application.
In the last two years, the most part of Rails plugins offers the ability to be installed as a plugin or as a Gem. With Rails 3 and the arrival of Bundler, I'm sure plugins are going to be deprecated in favor of Gems.
That are 2 different repositorys,
maybe you shoult try
config.gem 'delayed_job', :source => http://github.com/collectiveidea/delayed_job.git
Look at: http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies
Btw. maybe you want to look at a maybe better solution: resque - see http://ruby-toolbox.com/categories/queueing.html for a comparison of used queing gems
When you install a gem it will be available for all apps, in case you use a plugin - just for an app it's installed into.
The basic difference is a gem is something that gets installed on the system running your Rails application, whereas a plugin is installed along with your application, plugin does not get installed on the system level.
suppose you are using rvm and let us take this example.
we have two applications app1 and app2
both are running on a common rvm gemset named gemset1
when you add a gem in the gemfile of app1 and run bundle install and then being in the same rvm gemset which is gemset1, if you run the second app app2 the gem will be available in the second application as well
Whereas with the plugin it will not be the case because plugins get installed on application level and not at the system level

Resources