Useful gems

6
Useful Gems Dont reinvent the wheel, just realign it.

Transcript of Useful gems

Page 1: Useful gems

Useful Gems Dont reinvent the wheel, just

realign it.

Page 2: Useful gems

Google DriveA Ruby library to read/write files/spreadsheets in Google Drive/Docs. Create local CSV file and upload it to drive.

Time taken - 1-2 minutes for 5000+ contacts.

Create spreadsheet on Google and upload stream of data.

Time taken - More than 5-6 hours for 5000+ contacts.

Page 3: Useful gems

Lets you find ActiveRecord objects by year, month, fortnight, week and more!Post.by_year(2013) # all posts in 2013Post.before(Date.today) # all posts for before todayPost.yesterday # all posts for yesterday

ByStar(by_*)

Page 4: Useful gems

Activerecord Importactiverecord-import is a library for bulk inserting data using ActiveRecord.One of its major features is following activerecord associations and generating the minimal number of SQL insert statements required, avoiding the N+1 insert problem.

An example probably explains it best. Say you had a schema like this: Publishers have Books Books have Reviews and you wanted to bulk insert 100 new publishers with 10K books and 3 reviews per book.

This library will follow the associations down and generate only 3 SQL insert statements - one for the publishers, one for the books, and one for the reviews.

In contrast, the standard ActiveRecord save would generate 100 insert statements for the publishers, then it would visit each publisher and save all the books: 100 * 10,000 = 1,000,000 SQL insert statements and then the reviews: 100 * 10,000 * 3 = 3M SQL insert statements,

Page 5: Useful gems

CocoonDynamic nested forms using jQuery made easy; works with formtastic, simple_form or default forms.

How it works?

Example

Page 6: Useful gems

OxA fast XML parser and Object marshaller as a Ruby gem.

Code example