class Jar < ActiveRecord::Base
belongs_to :task
attr_accessible :name, :revision
+
+ include JsonWithoutTimestamps
+ def as_json(options = {})
+ super options.merge({:except => [:task_id]})
+ end
end
belongs_to :teacher
has_many :tasks
attr_accessible :name
+
+ include JsonWithoutTimestamps
+ def as_json(options = {})
+ super options.merge({:methods => [:task_ids, :teacher], :except => [:teacher_id]})
+ end
end
belongs_to :lecture
has_one :jar
attr_accessible :name
+
+ include JsonWithoutTimestamps
+ def as_json(options = {})
+ super options.merge({:methods => [:jar], :except => [:lecture_id]})
+ end
end
class Teacher < ActiveRecord::Base
has_many :lectures
attr_accessible :name
+
+ include JsonWithoutTimestamps
end
# -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
- # config.autoload_paths += %W(#{config.root}/extras)
+ config.autoload_paths += %W(#{config.root}/extras)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
--- /dev/null
+module JsonWithoutTimestamps
+ def as_json(options = {})
+ super options.merge({:except => (options[:except] || []) + [:created_at, :updated_at]})
+ end
+end