Skip to main content

Git branch and basic commands and rails3 to rails4

Rails 3 to Rails 4 Migrations



Ruby Version
2.2.2
Rails Version
4.2.3
Modification files

1)Gemfile
Latest Gems related versions
2)Routes
Change the match method with via get or post
3)Controllers
New params creating and updating the data.
i)params.require(:person).permit(:name, :age)

4)Models
Active Record queries need to change
i)Profile.where(“code is not null”)
Profile.where.not(code: null)
ii)Write the scopes in Models
5)Javascripts,stylesheets,images_paths
Move the javascriptfiles and stylesheets to assets folder
6)Facebook,Linkedin,Twitter apis need to change
Code changes Latest versions of the API




Git Related Commands

git branch
List of branches for the git
git chekout -b newbranchname(Like rails4_migration)
Creating the new branch
git checkout branchname(Like rails4_migration)
Switching branche one branch to another branch
git fetch
It will pull the all branches in git
git pull
Pull the particular branch
git add . (or) git add file_name
Add the what are the files need to be push
git commit -m “purpose of commit”
Commit the code
git push origin branchname
Push the code to git
git stash (or) git checkout
Local changes Not required
git statsh pop
It will merge the local and server files.If conflicts are there it will display the file names.
Files inside the << updated stream
git branch -d branchname(Like rails4_migration)
Delete the git branch
Mandatory:While deleting the branch move to another branch.If you are same branch you cannot delete the branch

Comments

Post a Comment

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"]