Skip to content

Instantly share code, notes, and snippets.

@descovi
Created March 8, 2012 16:30
Show Gist options
  • Save descovi/2001935 to your computer and use it in GitHub Desktop.
Save descovi/2001935 to your computer and use it in GitHub Desktop.
rails 3 validation outside model (active record)
########
class ActivationCode
include ActiveModel::Validations
attr_accessor :activation_code
validates :activation_code, :presence => true
def initialize(activation_code)
@activation_code = activation_code
end
end
########
class CheckController < ApplicationController
def activation
u = ActivationCode.new :activation_code => params[:code]
u.valid?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment