Multipage Forms in Rails

I have a rather complicated model with many fields, associations has_many, images added image_column, etc.

A new object will be added using a multi-page form (8 steps). How can I perform validation and distribution between these steps?

I think it validation_groupcan be useful for determining validations for each step, but what about the overall design?

+5
source share
3 answers

Presenter (Jay Fields Rails: Presenter Pattern) / .

+6

, . step_1, step_2, , . , , , 3 1. , , , , . , , ; 2 , 3, step_3, step_2 , 2 .

, 1 , "" , 0, 1 .

(, 3, 5).

, 'name' 'email'. step_2 , params[:name] params[:email] . , . 2 "" "". step_3 , params[:age] params[:gender] , , 1, URL 3 . .

+4
class Campaign < ActiveRecord::Base
    with_options(:if => lambda { |campaign| campaign.on_or_past_step(:spam_can) }) do |spam_can|
      spam_can.validates_associated  :spam_can
      spam_can.validates_presence_of :spam_can
    end
  def on_or_past_step
   :
   :
  end
end

, , . AASM, , . , , . , ?

0
source

All Articles