>All Tutorials 
Ajax and .NET Ajax and .NET RSS XML
Ajax and ColdFusion Ajax and ColdFusion RSS XML
Ajax and Java Ajax and Java RSS XML
Ajax and PHP Ajax and PHP RSS XML
Ajax and SOA Ajax and SOA RSS XML
Ajax Goodies Ajax Goodies RSS XML
Ajax Tool Ajax Tool RSS XML
Facebook MockAjax Facebook MockAjax RSS XML
Google Web Toolkit Google Web Toolkit RSS XML
JavaScript Framework JavaScript Framework RSS XML
Ruby on Rails Ruby on Rails RSS XML
Technique Introduction Technique Introduction RSS XML
Without XMLHttpRequest Without XMLHttpRequest RSS XML
Yahoo! UI Yahoo! UI RSS XML

19 Rails Tricks Most Rails Coders Don't Know - rails ruby code july pm method great tricks

 
Registered tutorials: 501
Registered Users: 24390



Rating: 4 out of 4 votes cast


  
Category: Ruby on Rails

Tags Map

activerecord activerecordstore actsasnestedset actsastree agree application array article august benchmark bit blog book change chat check code coders common community controller create data default defaults documents dynamic easy elements en engines exception faster fetching files forum full globalize good great helper helpers html id item jobs july learn list locale lot method methods model models news nil number numbertocurrency oleg output override paul peter place plugin plugins pm post powerful problem project queries rails read request return returns ruby run schemetype send separate session sessions set settings shown sign simple site snippets specific store tasks test testing tests thought tips title tosentence tricks true urls user users variable views work works write xml yaml

Keyword Cloud Navigation Map

19 Rails Tricks Most Rails Coders Don't Know

Digg this   Post to del.icio.us

Abstract: Great article covering tricks and tips that can make your Rails application or code more efficient

When looking at my own Rails code and that of the community as a whole, I often see places where certain Rails techniques could have been used, but weren't. As much for my own memory as yours, I thought I'd list down some Rails tricks and tips that can make your application or code more efficient:

Benchmark logic in your controller actions - It's really easy. Use the benchmark class method available on all your models like this:

User.benchmark("adding and deleting 1000 users") do

	1000.times do
		User.create(:name => 'something')

		x = User.find_by_name('something')
		x.destroy

	end
end

Of course, your code would be a lot better ;-) The regular SQL logs are not shown when within the benchmark sections. Only the benchmark results are shown.


Read Full Tutorial...



Reviews:

Rate and Review This Site

No reviews yet


Statistic Information About this Resource:


Total Hits: 675
Unique Hits: 526


  Daily Weekly Monthly
  Unique Total Unique Total Unique Total
Average 0.1 0.1 1.4 1.6 10.9 13.7
Current 0 0 1 1 5 5
Previous 1 1 0 0 9 11
Jul 22 0 0 3 3 0 0
Jul 21 0 0 1 1 42 56
Jul 20 0 0 4 5 8 10
Jul 19 0 0 0 0 25 29
Jul 18 0 0 2 2 0 0
Jul 17 0 0 1 2 10 13
Jul 16 0 0 2 2 8 11
Jul 15 0 0 0 0 2 2
Highest 10 12 31 41 77 100


Script Execution Time: 10.76358 | SQL Queries: 10 | Members: 501
Ajax Tutorial Top List - Powered by Aardvark Topsites PHP 5.1.2