From 9dd67fce25d3993a0ee494506ba246a45d395e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 21 Feb 2010 08:47:37 +0100 Subject: Add to_key and to_param methods to ActiveModel::Conversion. --- activemodel/test/models/contact.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'activemodel/test/models') diff --git a/activemodel/test/models/contact.rb b/activemodel/test/models/contact.rb index f9fb0af027..dbdb8539b7 100644 --- a/activemodel/test/models/contact.rb +++ b/activemodel/test/models/contact.rb @@ -1,7 +1,13 @@ class Contact - attr_accessor :name, :age, :created_at, :awesome, :preferences + include ActiveModel::Conversion + + attr_accessor :id, :name, :age, :created_at, :awesome, :preferences, :new_record def initialize(options = {}) options.each { |name, value| send("#{name}=", value) } end + + def new_record? + defined?(@new_record) ? @new_record : true + end end -- cgit v1.2.3