Skip to main content

What is gemfile.lock in rails?

What is gemfile.lock in rails?

What is Gemfile.lock? or What is the difference between Gemfile and Gemfile.lock? these are the common questions that you come across while starting development with Rails project.


What is Gemfile?

    Gemfile is the file in which you can mention which gems (kind of Third Party libraries) that you want to use for your Rails application
    Gemfile lists the gems that you want to use for your development
    Syntax:
        gem ‘rails'
            This mentions that gem with name ‘rails’ has to be used in Project context
    Whenever you bundle install, then bundler finds the gems listed in the Gemfile and it installs latest stable version for the gems listed in the Gemfile
    You can specify which version to be used for the rails development:
        gem 'rails', ‘3.0.5'
        This will install the specific version of the rails i.e. version 3.0.5
    You can read more regarding Gemfile here


What is Gemfile.lock?

    Gemfile.lock is created when bundler installs the specific version for the gems that are listed in Gemfile
    It records the version of the gem and name of the gem in file Gemfile.lock
    Thus, Gemfile.lock contains actual gem name with version with which your application was configured by the bundler
    Thus, Gemfile.lock is the file with actual gem version configuration
    Thus answer to what is gemfile.lock is - File with gems configured for your Rails applications along with the exact versions
    This file can be updated when you change gems listed in the Gemfile and also updating it using the bundler

Comments

Popular posts from this blog

Gem::LoadError (Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).?

Gem::LoadError (Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).) In rails?


1)change the gemfile in mysql version
 gem 'mysql2'

2)Change to mysql2 version
 gem 'mysql2','0.3.20'

Active Scaffold : Add radio buttons to your form ruby on rails ?

Active Scaffold : Add radio buttons to your form ruby on rails ?

The way to add radio buttons to your active scaffold create/update from is as shown below

#Controller

class UsersController < ApplicationController
active_scaffold :user do |config|
config.label = “Users”
config.columns = [:name, :gender]
config.columns[:gender].form_ui = :radio
config.columns[:gender].options[:options] = [['Male', '1'], ['Female','2']]
end
end

Get user accessing ip address in rails?

Get user accessing ip address rails?

request.ip ->returns the ip, whether is is a local proxy ip (localhost address) or not.
*request.remote_ip -> is smarter and gets the ip address of the client outside of local proxies.
3)If you are using apache in front of a mongrel, then remote_ip will return the source address of the request, which in this case will be local host because the Apache web server is making the request, so instead put this in your controller:

@remote_ip = request.env["HTTP_X_FORWARDED_FOR"]