ActiveModel without rails
Asked Answered
C

2

6

Is possible use ActiveModel without rails?. Is possible use ActiveModel in desktop application?

Chigoe answered 6/12, 2010 at 1:43 Comment(0)
A
5

With Rails 3 you can! Check out this post on Rubyinside.com

Argumentum answered 6/12, 2010 at 3:2 Comment(0)
E
1

Yes, for example using the validations:

require 'active_model'

class Cat
  include ActiveModel::Validations

  attr_accessor :id, :name

  validates_presence_of :name
  puts "meow!"

end

Testing out the class above:

$ irb -r ./cat.rb
meow!
irb(main):002:0> cat = Cat.new
=> #<Cat:0xb99e44>
irb(main):003:0> cat.valid?
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
=> false
irb(main):004:0> cat.name = "puss"
=> "puss"
irb(main):005:0> cat.valid?
=> true
Exude answered 30/7, 2014 at 0:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.