balaji rajagopal
2008-Dec-04 06:10 UTC
One Controller+Five tables+ Five forms( 5 pages)+One model
Hi I have 5 forms(5 stages) to create my rails application.im using One Controller+Five tables+ Five forms( 5 pages)+One model/ 1st form: to enter the data and click the next button.To get the values in session. 2nd form: to enter the data and click the next button.To get the values in session. 3rd form: to enter the data and click the next button.To get the values in session. 4th form: to enter the data and click the next button.To get the values in session. 5th form: to enter the data and click the create button.To store the data to corresponding table. ------------------------------------------------------------------------------------------------ class WizardController < ApplicationController def wizard if params[:stage].nil? @stage = 1 @resort_basic = ResortBasic.new {} @resort_basic.resortclassid=params[:resortclass][:resortclassid] @resort_basic.resortname=params[:resortname] @resort_basic.resorttypeid=params[:resorttype][:resorttypeid] @resort_basic.seasonid=params[:seasontype][:seasontypeid] @resort_basic.website=params[:website] # @resort_basic.save() session[:resort_basicObj] = @resort_basic # Or whatever model is storing your stuff elsif params[:stage].to_i ==1 # @stage = params[:stage].to_i==1 @dummyObj = session[:resort_basicObj] # @dummyObj.save() @resort_contactdetail = ResortContactdetail.new{} @resort_contactdetail.resortid=@dummyObj.id @resort_contactdetail.firstname= params[:firstname] @resort_contactdetail.lastname= params[:lastname] @resort_contactdetail.designation= params[:designation] @resort_contactdetail.email_id= params[:email_id] @resort_contactdetail.mobile= params[:mobile] @resort_contactdetail.telephone1= params[:telephone1] @resort_contactdetail.telephone2= params[:telephone2] @resort_contactdetail.fax= params[:fax] # @resort_contactdetail.save() session[:resort_contactdetailObj] = @resort_contactdetail elsif params[:stage].to_i ==2 # @stage = params[:stage].to_i ==2 @dummyObj1 = session[:resort_contactdetailObj] # @dummyObj1.save() @resort_address = ResortAddress.new{} # @resort_address.resortid=@dummyObj1.id @resort_address.street= params[:street] @resort_address.area= params[:area] @resort_address.districtid= params[:district][:districtid] @resort_address.cityid= params[:city][:cityid] @resort_address.stateid= params[:state][:stateid] @resort_address.countryid= params[:country][:countryid] @resort_address.pincode= params[:pincode] # @resort_address.save() session[:resort_addressObj] = @resort_address elsif params[:stage].to_i ==3 # @stage = params[:stage].to_i ==3 # @dummyObj2 = session[:resort_addressObj] # @dummyObj2.save() @resort_additionaldetail = ResortAddtionaldetail.new{} # @resort_additionaldetail.resortid=@dummyObj2.id @resort_additionaldetail.aminity= params[:aminity] @resort_additionaldetail.directions= params[:directions] @resort_additionaldetail.transport= params[:transport] @resort_additionaldetail.map= params[:map] @resort_additionaldetail.pickupoffered= params[:pickupoffered] @resort_additionaldetail.email_id= params[:email_id] #@resort_additionaldetail.save <%23@resort_additionaldetail.save>() session[:resort_additionaldetailObj] = @resort_additionaldetail else params[:stage].to_i ==4 # @dummyObj3 = session[:resort_additionaldetailObj] # @dummyObj3.save() @resort_accomodation = ResortAccomodation.new{} # @resort_accomodation.resortid=@dummyObj3.id @resort_accomodation.roomtypeid= params[:roomtype][:roomtypeid] @resort_accomodation.singleoccupancyrate= params[:singleoccupancyrate] @resort_accomodation.doubleoccupancyrate= params[:doubleoccupancyrate] @resort_accomodation.extrapersoncost= params[:extrapersoncost] @resort_accomodation.numberofrooms= params[:numberofrooms] @resort_accomodation.availablerooms= params[:availablerooms] @resort_basic.save() @resort_contactdetail.save() @resort_address.save() @resort_additionaldetail.save() @resort_accomodation.save() end @next_stage = @stage + 1 #@wizard_data <%23@wizard_data> = session[:wizard_data] render :template => ''wizard\\stage''+@next_stage.to_s end end i used the code and not stored the value in database.im only doing this rails project. Please help me. Thanks and Regards Balaji --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---