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

Get the Current url in ruby on rails

request.refererrequest.fullpathrequest.fullpath.split("?")[0]request.referer or request.env['HTTP_REFERER'] your controller to get the referer url. 

--------------------
request.original_url
request.url
request.host_with_port
<link rel="canonical" href="<%= request.url %>" />
<%=request.path%>
How can I get the current absolute URL in my Ruby on Rails view?
The request.request_uri only returns the relative URL.
request.env['REQUEST_URI']

 For Rails 3.2 or Rails 4 you should use request.original_url to get the current URL. More detail.

For Rails 3: You want "#{request.protocol}#{request.host_with_port}#{request.fullpath}", since request.url is now deprecated.

For Rails 2: You want request.url instead of request.request_uri. This combines the protocol (usually http://) with the host, and request_uri to give you the full address

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