Created
March 8, 2012 16:30
-
-
Save descovi/2001935 to your computer and use it in GitHub Desktop.
rails 3 validation outside model (active record)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######## | |
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