Posts

Showing posts from 2016

Simple way of importing and exporting excel, csv file for ruby on rails application using roo gem

Image
Create a Rails Application where student data can upload as excel and can be download as excel file. #Gemfile gem 'roo' #Student Table migration File class CreateStudents < ActiveRecord::Migration   def change     create_table :students do |t|         t.string :name         t.integer :roll_no         t.integer :marks1         t.integer :marks2         t.integer :marks3         t.integer :avg       t.timestamps null: false     end   end end #student_controller.rb class StudentController < ApplicationController   def s_home     @products = Student.all     respond_to do |format|       format.html       format.csv { send_data @products.to_csv }       format.xls { send_data @products.to_csv(col_sep: "\t"), filename: 'your...

All About Route in Rails

Image
What is HTTP? The Hypertext Transfer Protocol (HTTP) is designed to enable communications between clients and servers. HTTP works as a request-response protocol between a client and server. A web browser may be the client, and an application on a computer that hosts a web site may be the server. Get vs Post GET - Requests data from a specified resource. POST - Submits data to be processed to a specified resource. #Rails -- > config/route.rb root 'pages#index'   : default route (http://localhost:3000 it will go to this route) get 'authentication' => "login#authentication", (http://localhost:3000/authentication - it will goto login#authentication) get 'authentication' => "login#authentication", defaults: {format: 'json'}  now can represent data in json format.