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 .
No comments:
Post a Comment