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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
I looks like @step tells you what step the user is currently at, and that @direction tells you whether he pressed the "previous step" or "next step" button. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sharagoz -- wrote:> I looks like @step tells you what step the user is currently at, and > that @direction tells you whether he pressed the "previous step" or > "next step" button.So if that''s the case, why would the params method be captured here for both :step and :direction. Thanks for the response. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Feb 7, 8:21 am, John Merlino <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Sharagoz -- wrote: > > I looks like @step tells you what step the user is currently at, and > > that @direction tells you whether he pressed the "previous step" or > > "next step" button. > > So if that''s the case, why would the params method be captured here for > both :step and :direction.What? You''ll need to explain what you mean by "the params method be captured" if you''re looking for an answer... --Matt JOnes -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.