-
Notifications
You must be signed in to change notification settings - Fork 0
Form generator
Ante Wall edited this page Jul 8, 2016
·
2 revisions
Ascent have a custom built form generator to automatically generate a form with all its attributes. To customize it use the following methods below
These fields are automaticly excluded from being generated
id, created_at, updated_at
To exclude fields from being automatically generated you can configurate you model from within your model definition file. Example:
class ModelName
ascent do
exclude 'column_name1', :column_name2
end
endIf you want to scope certain collections you can do that by defining the column name for the association followed by a Proc
The proc can take 2 arguments, the first is the scope of the model, the other one is the current object being modified, note that this can be nil if the object is not yet created.
Example:
class ModelName
ascent do
collection_scope :comment_id, proc {|scope, object|
scope.where(published: false)
scope.where.not(id: object.id) if object.present?
}
end
end