A lot of times websites simulate wizards where you enter some
information and click the next button to move to the next step before
completing the form. I'm looking at some code that attempts to achieve
this, but it has a "direction" parameter that I'm not sure what it does.
All I know is that it is either a -1 or 1 value:
def sequence(method_pre)
@step = (params[:step] || 0).to_i
@direction = (params[:direction] || 1).to_i
if @step == 0
@step = 1
elsif @direction == -1
send("#{method_pre}_update_values", @step)
@step -= 1
elsif send("#{method_pre}_validate", @step)
if @step == send("#{method_pre}_num")
send("#{method_pre}_final")
else
@step += @direction
end
else
flash.now[:error]
I'm not exactly sure what direction does here and why it's only a -1 or
1 value. Also, I noticed these possible combinations:
(step 1 direction 1)(step 2 direction 1)(step 3 direction 1)(step 0
direction 1)(step 2 direction -1)(step 3 direction -1)
Any ideas? Thanks.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.