Saturday 14 February 2015

Use of respond to in rails 4




Its a way of responding to the client based on what they are asking for, if the client asks for HTML, Rails will send back HTML to the client, if they ask for XML then XML and also Json. 

By using respond to in rails we present the data or we sending the data according to client requirement by this method.

Example : 

 respond_to do |format|

     format.html { redirect_to(person_list_url}     
     format.xml  {render :xml => @modelname }
     format.json {render :json => @modelname.as_json}
     format.js {}

end


Here we send data in multiple format according to client requirement.  but in html format we redirect the url for html request for a particular page..in html format.

For more information go on =>  respond_to in rails 4 .








Saturday 7 February 2015

what is mime type and respond_to in rails

respond_to:    and  MIME Type.
--------------------------------------------------------

respond_to is a method of rails that defines different formats that your actions, well , respond to.
And the formate of file is maintained in rails mime_type.

#require 'action_controller/mine_types'

#actionpack/lib/actioncontroller/mimetypes.rb 

 and if you need to use a MIME type which isn't supported by default, you can register your own handler in config/initializers/mime_types.rb

MIME::Type.register "image/jpg", :jpg

And Respond to also allows you to specify a common block for different formats by using any:

def index
  @people = Person.all

  respond_to do |format|
    format.html
    format.any(:xml, :json) { render request.format.to_sym => @people }
  end
end
here we see the block of respond_to is use for render different formats by using do block.

Now! one thing is important to notice the render file extension should be like this..
according to this block .. on index action it will be render two file ,
1st -- index.xml.erb, and 2nd is index.json.erb .






 

Friday 6 February 2015

Basic Git Command

Git is use for VCS ( Version Control System). To use for records changes to a file or set of files over time so that you can recall specific versions according to programmer requirement.
Git allow you to revert files back to a previous state , revert the entire project back to a previous state , and also compare changes over time , you also able to see who last modified the code in file or any changes.

Here i write some most important and basic command of Git for Beginner Git User.

1.  How to install Git in Ubuntu  ?
--------------------------------------------------------------
/$ sudo apt-get update
/$ sudo apt-get install git
--------------------------------------------------------------

2. How to Set Up Git ?
--------------------------------------------------------------

/$ git config --global user.name "Your Name"
/$ git config --global user.email "youremail@domain.com"

----------------------------------For see all Configuration--------------------
/$ git config --list
-------------------------------------------------------------------------------------------------


Now this is some Basic Git Commands .


a) For create a new local repository
 =>  git init

b) Create a working copy of a local repository
 =>    git clone /path/to/repository

C) For  a remote server, use  
 => git clone username@host: /path/to/repositroy    

d) Add files (one or more files)
=> git add <filename>

e) Commit directory for local changes.
=> git commit -m "commit message"

f) Send changes to master branch of your remote repositor.
=> git push origin master

g) List the file you've changed in local branch and those you still need to add or commit.
=> git status

h) If you haven't connected you local repository to a remote server , then use this command to add the server to be able to push to it.
=> git remote add origin <server>

i) List all currently configured remote repositories:
=> git remote -v

 *Switch from one branch to another:
=> git checkout <branchname>

*For create a new branch.
=> git checkout -b <branchname>

*For check you current branch
=> git branch

*For delete the branch
=> git branch -d <branchname>

*Push all branches to your remote repository.
=> git push --all origin

j) Update your remote repository.
=> git pull


===================================
This is some use full and very basic command of git .
















Salesforce CRM vs. Zoho: A Comparative Analysis

Introduction: Selecting the right customer relationship management (CRM) software is crucial for businesses seeking to streamline their sal...