class Paramount::Model

Attributes

model[RW]

Public Class Methods

find(id) click to toggle source

This 'factory' meant for show/edit takes no params and uses the model attributes to seed the virtus attributes usage in controller : BookParam.find(params)

# File lib/paramount/model.rb, line 19
def self.find(id)
  model = model_class.find(id)
  new(model.attributes, model)
end
model_class() click to toggle source

def self.model_name

raise "self.model_name needs to be defined"

end

# File lib/paramount/model.rb, line 12
def self.model_class
  @klass ||= model_name.name.constantize
end
new(params = nil, model = nil) click to toggle source
Calls superclass method
# File lib/paramount/model.rb, line 24
def initialize(params = nil, model = nil)
  @model= model
  params ||= model.attributes
  super(params)
end

Public Instance Methods

id() click to toggle source
# File lib/paramount/model.rb, line 30
def id
  model.id
end
path() click to toggle source
# File lib/paramount/model.rb, line 40
def path
  [:edit, model]
end
persisted?() click to toggle source
# File lib/paramount/model.rb, line 44
def persisted?
  model.new_record? ? false : true
end
save() click to toggle source
# File lib/paramount/model.rb, line 34
def save
  assign
  model.save if valid?
end
Also aliased as: update
update()
Alias for: save