28 Feb '16, 6pm

Different ways how to do Rails validations

Different ways how to do Rails validations

# app/model/identity.rb class Identity < ActiveRecord::Base # nice thin model doing other improtant model stuff end # app/services/oauth_identity_creator.rb class OauthIdentityCreator include ActiveModel::Validations attr_accessor :uid, :provider validates_presence_of :uid, :provider, :auth def create if valid? identity .tap do |i| i.uid = uid i.provider = provider end .save end end def identity @identity ||= Identity.new end end # app/services/identity_updater.rb class IdentityUpdater include ActiveModel::Validations attr_accessor :submitted_identity, :identity_id validates_presence_of :submitted_email validates_format_of :submitted_email, with: EMAIL_REXP def update if valid? identity .tap { |i| i.submitted_email = submitted_email } .save end end def identity @identity ||= Identity.find_by!(id: identity_id) end end # app/controllers/oauth_callback_controller.rb class OAu...

Full article: http://www.eq8.eu/blogs/22-different-ways-how-to-do-rails...

Tweets

#Why is Rails to_json giving a different result...

abizy.com 05 Mar '16, 4pm

We do not share, store or cache any illegal files on this blog. We only share digital contents those are licensed under “C...

9 Simple Ways To Start Exercising Again After A...

Sometimes life happens and we can get a little off track. Family commitments pop up, sickness kicks in, or you get stuck w...

10 Ways The Sneaker Game Was Different Before T...

kicksonfire.com 21 Feb '16, 8pm

Old sneakerheads like to lament about days gone by to anybody that will listen to them, but they don’t even have to go tha...

Different kinds of Insurance Protection and Roughly how much is Adequate

Different kinds of Insurance Protection and Rou...

investmentmoats.com 29 Feb '16, 11pm

Different kinds of Insurance Protection and Roughly how much is Adequate March 1, 2016 by Kyith Leave a Comment The majori...

How I Do Rails Controllers

rubyflow.com 06 Mar '16, 1pm

× The Ruby and Rails community linklog Made a library? Written a blog post? Found a useful tutorial? Share it with the Rub...

6 Ways Grow a Muffin Top Fast (or How to Avoid It)

6 Ways Grow a Muffin Top Fast (or How to Avoid It)

ecosalon.com 28 Feb '16, 8am

Yay, spring is right around the corner! OMG, spring is right around the corner! If you seem to have grown a muffin top ove...

How DHH organizes his Rails controllers

rubyflow.com 28 Feb '16, 10am

× The Ruby and Rails community linklog Made a library? Written a blog post? Found a useful tutorial? Share it with the Rub...

"Ruby on Rails-style development comes to Apple...

infoworld.com 27 Feb '16, 11am

Apple's trendy Swift language is getting a Web framework inspired by the popular Ruby on Rails MVC framework. Open source ...

10 ways to become a better runner without actually logging any miles:

10 ways to become a better runner without actua...

womensrunning.competitor.com 28 Feb '16, 12am

Foam roll: If you’re running a lot, you’ll really feel those tight muscles. Loosen them up to help prevent injuries with t...

#ruby

#ruby

jeromedalbert.com 28 Feb '16, 10am

Remember the projects you worked on where controllers were 200+ lines long AND this was only a small portion of the code r...