Ruby on Rails

FacebookTwitter

Sample REST API in Rails | codedecoder

I have tried to define and explain API in this post. I again, put it in simple words “ API is program which let the user to use methods of your application from outside the application “. I will create a REST API here which will implement CRUD ( create, read, update, delete ) operation on users table from outside the application. I assume you all have implemented CRUD for user in your application. The API implementation will remain same, with below difference. http://codedecoder.wordpress.com/2013/02/21/sample-rest-api-example-in-rails/
Social Media Integration

American Date Parsing

Wave the flag! I recently ran into an interesting issue while working on a Rails 3, Ruby 1.9.3 project. My needs were simple: I had a single text field that allowed the user to enter a date in MM/DD/YYYY format. http://library.edgecase.com/american-date-parsing
http://everydayrails.com/2012/03/19/testing-series-rspec-models-factory-girl.html

How I learned to test my Rails applications, Part 3: Model specs

March 19, 2012 We’ve got all the tools we need for building a solid, reliable test suite—now it’s time to put them to work. We’ll get started with the app’s core building blocks—its models.

Auditing via paper_trail (change history) · gregbell/active_admin Wiki

https://github.com/gregbell/active_admin/wiki/Auditing-via-paper_trail-(change-history) paper_trail is a gem used for auditing and versioning of your models. We can easily use it with active_admin to show a list of recently modified items in the admin screen. Example: Integration instructions Install PaperTrail as a gem via your Gemfile : gem 'paper_trail' Generate a migration which will add a versions table to your database: rails generate paper_trail:install Run the migration: rake db:migrate Add user_for_paper_trail to controller so paper_trail knows which user updated the item. (optional)
http://heavysixer.github.com/blog/2011/12/01/transactions-in-rails Recently I was tasked to write tests for the transactions of an existing application. This gave me the opportunity to learn more about the codebase, while also improving the test coverage. Generally, most of the transaction code looked fine.

Transactions In Rails - Mark Daggett's Blog

http://iqbalfarabi.net/2011/06/07/rails-nested-form-with-has-many-through-association-part-2/

Rails Nested Form with Has Many Through Association (Part 2) | IqbalFarabi.net

What about editing? I create this post to answer Pierre’s question in the comment section in my previous tutorial here . The edit part is actually not much different from the new part. Therefore, I wanted to just edit that previous post. But somehow, there is something wrong with my blog, I could not update that post. Well, I tried this and that and nothing worked while my lunch time is almost over now.
http://andreys.info/blog/2008-03-15/delete-svn-folders-on-your-mac Sometimes you need to get rid of .svn hidden folders on your Mac. In my case it was about resyncing my local working copy with client subversion repository. Everything was broken at both ends.

Delete .svn folders on your Mac | Andrey's Daily Light and Shadow | Photo Blog

Efficient Updates & Data Import in Rails

By Ilya Grigorik on July 11, 2007 /* Typical ActiveRecord insert * number of records = slow */ mysql > insert into widgets ( title , price ) values ( 'gizmo' , 5 ); Query OK , 1 row affected ( 0 . 01 sec ) /* Multi-record insert with ar-extensions * 1 insert = fast */ mysql > insert into widgets ( title , price ) values ( 'gizmo' , 5 ),( 'super-gizmo' , 10 ),( 'hammer' , 6 ); Query OK , 3 rows affected ( 0 . 01 sec ) Records : 3 Duplicates : 0 Warnings : 0 ActiveRecord is a fantastic database abstraction layer and is rightfully one of the core pillars of Rails, but that doesn't mean we can't improve it. http://www.igvita.com/2007/07/11/efficient-updates-data-import-in-rails/
activerecord-import activerecord-import is a library for bulk inserting data using ActiveRecord. Note: activerecord-import requires Rails 3.×. It does not work with Rails 2.×.

activerecord-import · zdennis/activerecord-import Wiki

https://github.com/zdennis/activerecord-import/wiki/