Thursday, 15 January 2015

javascript - Ruby on Rails complex forms -



javascript - Ruby on Rails complex forms -

i developing content management scheme needs of client , stuck. have create scheme in order manage products , prices. project tourist agency every "product price" has seasons, , each season there product category. each product category has prices. example:

i "creating" hotel (the product). must create "price periods" (low season, mid season etc). in each cost period create cost category (for illustration "gold club rooms") , in each category create room cost (for illustration "double deluxe - 100$"). price_periods, price_groups , prices models association product. problem have create these in 1 form. thought of way pretty complex , did not manage, yet, create work properly...

in few words, created 2 step submission. 1 product , price_periods, , sec step price_category , cost (in triple nested form). looking more clean way build asking help. is there design pattern should follow? or book or reference?

please help :) sorry if "out of subject", stuck , appreciate help. in advance.

my models are:

product class product < activerecord::base # concerns include translatable translates :title, :description, :address # validations validates_presence_of :address_lat, :address_lon # associations has_and_belongs_to_many :product_categories has_many :product_translations has_many :prices has_many :price_periods has_many :price_groups belongs_to :location accepts_nested_attributes_for :product_translations accepts_nested_attributes_for :prices accepts_nested_attributes_for :price_periods accepts_nested_attributes_for :price_groups end price period class priceperiod < activerecord::base # associations has_many :prices belongs_to :product end price group class pricegroup < activerecord::base # associations has_many :prices belongs_to :product end price class cost < activerecord::base # associations belongs_to :product belongs_to :price_group belongs_to :price_period end

javascript jquery ruby-on-rails forms nested-forms

No comments:

Post a Comment