Created
January 26, 2017 15:49
-
-
Save zerothabhishek/c5894bd3bb5baca9a29bdb847efb9c2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FacilitiesServicesForm | |
include ActiveModel::Validations | |
include ActiveModel::Conversion | |
extend ActiveModel::Naming | |
# These are sort of like the has_many relation | |
attr_accessor :facilities_offerred, | |
:services_offerred | |
def initialize(params = {}) | |
@facilities_offerred = [] | |
@services_offerred = [] | |
assign(params) if params.present? | |
end | |
def load(args) | |
load_facilities | |
load_services_offerred | |
self | |
end | |
def assign(params) | |
assign_facilities(params) | |
assign_services(params) | |
self | |
end | |
def save(args) | |
save_facilities | |
save_trade_services | |
true | |
end | |
end | |
## show action: | |
## f = FacilitiesServicesForm.new | |
## f.load(some_models) | |
## Create action: | |
## f = FacilitiesServicesForm.new(params) | |
## f.save | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment