30 Jun '13, 1am

Object Oriented Rails – Writing better controllers

I have been doing a lot of mobile development lately, using Objective-C on iOS, and Java on Android. Since I’m also a Ruby developer, it makes a lot of sense for me to try and apply what I learn from each of these languages and frameworks whenever I can. Today I’m going to do my best in writing better controllers in my Rails app. When writing an app for Android, or iOS, I force myself not to use stubs or mocks, but instead I try to improve the object architecture and use dependency injection to write my testing code. Let’s take an example of code: class User validates_uniqueness_of :username end class RegistrationController < ApplicationController def create user = User.where(username: params[:username]).first user ||= User.new.tap do |new_user| new_user.username = params[:username] new_user.save! end render json: user end end Here we only need a username to register the u...

Full article: http://pivotallabs.com/object-oriented-rails-writing-bett...

Tweets

stripe_commerce Rails APP

rubyflow.com 30 Jun '13, 10pm

stripe_commerce Rails APP Posted by drhenner on July 01, 2013 — 0 comments I just launched stripe_commerce I gave a small ...

Which domain would be better?

forums.seochat.com 06 Jul '13, 1pm

I'm starting a small network of health sites with information and articles. I'm not sure which domain to use, though. I ha...

Sleep Better (And Longer) To Run Better

Sleep Better (And Longer) To Run Better

running.competitor.com 02 Jul '13, 6pm

Sleep Better (And Longer) To Run Better By Deb Dellapena Published 7 hours ago comments Tweet Share Share Print Taking nap...

@brookr you have to put v3.2.13 in the url now

guides.rubyonrails.org 05 Jul '13, 7pm

# routes.rb root :to => 'home#index' resources :posts # home_controller.rb class HomeController < ApplicationController de...

Openly Solving Real Problems via @pivotallabs

pivotallabs.com 29 Jun '13, 3pm

Like many modern software companies, Pivotal Labs develops open source software. Our approach to open source projects is r...

Dear Gilbert, This is the first time I am writing to you. Before I go on, I like to thank you for what you are...

Dear Gilbert, This is the first time I am writi...

transitioning.org 01 Jul '13, 1am

This is the first time I am writing to you. Before I go on, I like to thank you for what you are doing for the displaced S...

Top Ten Tips For Newsletter Writing

promotionworld.com 01 Jul '13, 12am

Writing newsletters is a good way to draw attention towards your business. It is cost effective and a reliable public rela...

[37s] 12 Spokes: Ruby on Rails Developer

jobs.37signals.com 03 Jul '13, 8pm

We’re 12 Spokes, full-service web and mobile development shop, based in Salt Lake City, Utah, with team members spanning t...

I probably would have used an encryptor *instan...

pivotallabs.com 01 Jul '13, 2am

During refactoring, private methods are created in order to: Eliminate duplication within the class Clarify confusing and/...

This is what I'm learning at Pivotal: And this ...

pivotallabs.com 24 Jun '13, 3pm

You’re a product owner, and you have an idea. In your mind, it’s pure, simple, and beautiful. You want to hold onto that i...