Ruby on Rails - gemfiles in ruby on rails- ruby on rails tutorial - rails guides - rails tutorial - ruby rails
Gemfiles
To start, gemfiles require at least one source, in the form of the URL for a RubyGems server. Generate a Gemfile with the default rubygems.org source by running bundle init. Use https so your connection to the server will be verified with SSL.
source "https://rubygems.org"
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
Next, declare the gems that you need, including version numbers.
gem 'rails', '4.2.6'
gem 'rack', '>=1.1'
gem 'puma', '~>3.0'
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
Most of the version specifiers, like >= 1.0, are self-explanatory. The specifier ~> has a special meaning. ~> 2.0.3 is identical to >= 2.0.3 and < 2.1. ~> 2.1 is identical to >= 2.1 and < 3.0. ~> 2.2.beta will match prerelease versions like 2.2.beta.12. Git repositories are valid gem sources, as long as the repo contains one or more valid gems. Specify what to check out with :tag, :branch. The default is the master branch.
gem 'nokogiri', :git => 'https://github.com/sparklemotion/nokogiri', :branch => 'master'
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
- If you would like to use an unpacked gem directly from the filesystem, simply set the :path option to the path containing the gem's files.
gem 'extracted_library', :path => './vendor/extracted_library'
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
- Dependencies can be placed into groups. Groups can be ignored at install-time (using --without) or required all at once.
gem 'rails_12factor', group: :production
group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'dotenv-rails'
end
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
- You can specify the required version of Ruby in the Gemfile with ruby. If the Gemfile is loaded on a different Ruby version, Bundler will raise an exception with an explanation.
ruby '2.3.1'