view - Rails controller : How to pass parameters between actions in wizard style? -


i'm trying build wizard style site creating object.
each step user inputs parameters. want create , persist object in db when parameters submitted @ final step.

class experimentscontroller < applicationcontroller   def wizard_step_1     render template: "experiments/wizards/step1"   end    def wizard_step_2     render template: "experiments/wizards/step2"   end    def wizard_step_3     binding.pry     # how access params in step 1 & 2 here?   end end  view step1 below: <%= form_tag(action: 'wizard_step_2') %>     <%= text_field_tag("user_name") %>     <%= submit_tag("next >>") %> <% end %>  view step2 below: <%= form_tag(action: 'wizard_step_3') %>     <%= text_field_tag("user_email") %>     <%= submit_tag("next >>") %> <% end %> 

i didn't put routes info here it's tested ok. when user visit step1 , input user name, when submitting form control goes wizard_step_2 , show view step2. here user inputs email , when clicking submit button execution goes action wizard_step_3. question how obtain user name , email user inputs in previous steps?

i'd thought gem wicked, , rails cache etc., , more or less don't fulfill needs. there decent way doing this?

i don't have huge experience this, may able benefit from: wizard forms railscast

i'd imagine type of setup save step 1, step 2, etc params session variables:

class experimentscontroller < applicationcontroller   def wizard_step_1     render template: "experiments/wizards/step1"   end    def wizard_step_2     render template: "experiments/wizards/step2"      #create session vars step1      session[:user][:name] = params[:user_name]   end    def wizard_step_3     binding.pry      #step2 passed params ;)     params[:user_name] = session[:user][:name]      end end  view step1 below: <%= form_tag(action: 'wizard_step_2') %>     <%= text_field_tag("user_name") %>     <%= submit_tag("next >>") %> <% end %>  view step2 below: <%= form_tag(action: 'wizard_step_3') %>     <%= text_field_tag("user_email") %>     <%= submit_tag("next >>") %> <% end %> 

i know example not dry, it's basis of i'd start at. essentially, need able persist data between instances of objects, lends entirely sessions


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -