Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
Parsing of XML data has high CPU usage
Convert simple Javascript to jQuery plugin
Active Record getting unique records
List the files in a directory without the directory name or the extension
clean the code
ohs system, recruitment software, hr software, oh&s software, human resources software, ohs software
Array parsing in a block
Learning JS
Type Safety
Euler Problem 2 solution
Popular
Parsing of XML data has high CPU usage
List the files in a directory without the directory name or the extension
Convert simple Javascript to jQuery plugin
Active Record getting unique records
Breadth first cartesian product iterator
php refactoring
first BST
Learning JS
Too many if statements
clean the code
Pastable version of
resource_controller: Redesign My API
<pre class='prettyprint' language='ruby'>class PostsController < ResourceController::Base # block syntax create do before { @post.user = current_user } response do |wants| wants.html wants.js end end # chain syntax update.failure.wants.js # hybrid syntax update.failure do flash "There was a problem saving your object." wants.js end end</pre> <pre class='prettyprint' language='ruby'>class PostsController < ResourceController::Base private def model_name 'blog_post' end def route_name 'article' end end</pre> <pre class='prettyprint' language='ruby'>class PostsController < ResourceController::Base private def object @object ||= end_of_association_chain.find_by_permalink(param) end def collection @collection ||= end_of_association_chain.find(:all, :page => {:current => params[:page], :size => 10}) end end</pre> <pre class='prettyprint' language='ruby'>class PostsController < ResourceController::Base actions :all, :except => :edit end</pre> <pre class='prettyprint' language='ruby'>class PostsController < ResourceController::Base belongs_to :user, :category end</pre> <a href="http://www.refactormycode.com/codes/137-resource_controller-redesign-my-api" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>