balaji rajagopal
2008-Dec-03 09:21 UTC
Multiple Forms and Multiple tables +One Model +One Controller
Hi Im using Multiple Forms and Multiple tables +One Model +One Controller in my rails application and give example code Please help me Thanks & 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 -~----------~----~----~----~------~----~------~--~---
Thorsten Müller
2008-Dec-03 10:01 UTC
Re: Multiple Forms and Multiple tables +One Model +One Controller
??? maybe I missed the details in some other post, but I have no idea, what exactly you want. please be more specific, otherwise nobody will be able to help you. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
balaji rajagopal
2008-Dec-03 10:55 UTC
Re: Multiple Forms and Multiple tables +One Model +One Controller
Hi
Im using Multiple Forms and Multiple tables +One Model +One Controller in my
rails application
I have 5 forms(5 stages) to create my rails application.
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.
Controller code:
-----------------------------------------------------------------------------------------------------------------------------
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.website=params[:website]
# @resort_basic.save()
session[:resort_basicObj] = @resort_basic # Or whatever model is storing
your stuff
else if
@stage = params[:stage].to_i
@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.save()
session[:resort_contactdetailObj] = @resort_contactdetail
else if
@stage = params[:stage].to_i
@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.countryid= params[:country][:countryid]
@resort_address.pincode= params[:pincode]
# @resort_address.save()
session[:resort_addressObj] = @resort_address
else if
@stage = params[:stage].to_i
@dummyObj2 = session[:resort_addressObj]
@dummyObj2.save()
@resort_additionaldetail = ResortAddtionaldetail.new{}
@resort_additionaldetail.resortid=@dummyObj2.id
@resort_additionaldetail.aminity= params[:aminity]
@resort_additionaldetail.pickupoffered= params[:pickupoffered]
@resort_additionaldetail.email_id= params[:email_id]
#@resort_additionaldetail.save()
session[:resort_additionaldetailObj] = @resort_additionaldetail
else
@stage = params[:stage].to_i
@dummyObj3 = session[:resort_additionaldetailObj]
@dummyObj3.save()
@resort_accomodation = ResortAccomodation.new{}
@resort_accomodation.resortid=@dummyObj3.id
@resort_accomodation.roomtypeid= params[:roomtype][:roomtypeid]
@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 = session[:wizard_data]
render :template => ''wizard\\stage''+@next_stage.to_s
end
end
end
end
end
I enter the data in 1st form and to click the next button.
I got error:
Template is missing
Missing template wizard/wizard.html.erb in view path
D:/RubyProjects/TestEcohols/app/views
but im using stage1.html.erb to stage2.html.erb.
Please help me.............
Thanks & 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
-~----------~----~----~----~------~----~------~--~---
Thorsten Müller
2008-Dec-03 11:22 UTC
Re: Multiple Forms and Multiple tables +One Model +One Controller
I do not really understand, what you are doing here, but: You are using "else if" without a condition several times, beneath the fact that the correct ruby syntax is elsif Then Ruby would interpret the following line: @stage = params[:stage].to_i as condition and the outcome of this is most likely not what you would expect. And all those "end'' show too, that the structure is a bit weird. I think, what you want to do would need something like this: def wizard if params[:stage].nil? ... elsif params[:stage].to_i == 1 ... elsif params[:stage].to_i == 2 ... else ... end render :template => ''wizard\\stage''+@next_stage.to_s end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
balaji rajagopal
2008-Dec-04 05:53 UTC
Re: Multiple Forms and Multiple tables +One Model +One Controller
Hi *Thorsten Müller*
your guideness very helpful for me. i used the code but i got bugs.
code
----------------------------------------------------------------------------------------------------------------------------------
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=-GHDnjl5KEZyez0ei9/+7zw@public.gmane.org
@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=-GHDnjl5KEZwmDwch+3WvLQ@public.gmane.org
@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=-GHDnjl5KEZypvc4acjH5xA@public.gmane.org
@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()
session[:resort_additionaldetailObj] = @resort_additionaldetail
else params[:stage].to_i ==4
# @dummyObj3 = session[:resort_additionaldetailObj]
# @dummyObj3.save()
@resort_accomodation = ResortAccomodation.new{}
# @resort_accomodation.resortid=-GHDnjl5KEZzVC6+XVkywBQ@public.gmane.org
@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 = session[:wizard_data]
render :template => ''wizard\\stage''+@next_stage.to_s
end
end
I have 5 forms(5 stages) to create my rails application.
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.
i used the code and not stored the value in database.im only doing this
rails project.
Please help me.
Thanks and Regards
Balaji
On 12/3/08, Thorsten Müller
<thorsten-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org>
wrote:>
>
> I do not really understand, what you are doing here, but:
>
> You are using "else if" without a condition several times,
> beneath the fact that the correct ruby syntax is elsif
>
> Then Ruby would interpret the following line:
> @stage = params[:stage].to_i
> as condition and the outcome of this is most likely not
> what you would expect.
>
> And all those "end'' show too, that the structure is a bit
weird.
>
> I think, what you want to do would need something like this:
>
> def wizard
> if params[:stage].nil?
> ...
> elsif params[:stage].to_i == 1
> ...
> elsif params[:stage].to_i == 2
> ...
> else
> ...
> end
> render :template => ''wizard\\stage''+@next_stage.to_s
> end
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
balaji rajagopal
2008-Dec-04 06:42 UTC
Re: Multiple Forms and Multiple tables +One Model +One Controller
Hi *Thorsten Müller* i got bugs: NoMethodError in WizardController#wizard You have a nil object when you didn''t expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.[] Please help me. Thanks and Regards Balaji On 12/4/08, balaji rajagopal <balajiece.rajagopal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi *Thorsten Müller* > > your guideness very helpful for me. i used the code but i got bugs. > > code > > ---------------------------------------------------------------------------------------------------------------------------------- > > 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=-GHDnjl5KEZyez0ei9/+7zw@public.gmane.org > > @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=-GHDnjl5KEZwmDwch+3WvLQ@public.gmane.org > > @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=-GHDnjl5KEZypvc4acjH5xA@public.gmane.org > > @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=-GHDnjl5KEZzVC6+XVkywBQ@public.gmane.org > > @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 have 5 forms(5 stages) to create my rails application. > > 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. > > > > i used the code and not stored the value in database.im only doing this > rails project. > Please help me. > > Thanks and Regards > > Balaji > > > On 12/3/08, Thorsten Müller <thorsten-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote: >> >> >> I do not really understand, what you are doing here, but: >> >> You are using "else if" without a condition several times, >> beneath the fact that the correct ruby syntax is elsif >> >> Then Ruby would interpret the following line: >> @stage = params[:stage].to_i >> as condition and the outcome of this is most likely not >> what you would expect. >> >> And all those "end'' show too, that the structure is a bit weird. >> >> I think, what you want to do would need something like this: >> >> def wizard >> if params[:stage].nil? >> ... >> elsif params[:stage].to_i == 1 >> ... >> elsif params[:stage].to_i == 2 >> ... >> else >> ... >> end >> render :template => ''wizard\\stage''+@next_stage.to_s >> end >> >> >> >> >--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
balaji rajagopal
2008-Dec-04 09:49 UTC
Re: Multiple Forms and Multiple tables +One Model +One Controller
Hi *Thorsten Müller*
I have 5 forms(5 stages) to create my rails application.
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.
controller code
----------------------------------------------------------------------------------------------------------------------------
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
# @dummyObj = session[:resort_basicObj]
# @dummyObj.save()
@resort_contactdetail = ResortContactdetail.new{}
# @resort_contactdetail.resortid=-GHDnjl5KEZyez0ei9/+7zw@public.gmane.org
@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
# @dummyObj1 = session[:resort_contactdetailObj]
# @dummyObj1.save()
@resort_address = ResortAddress.new{}
# @resort_address.resortid=-GHDnjl5KEZwmDwch+3WvLQ@public.gmane.org
@resort_address.street= params[:street]
@resort_address.area= params[:area]
@resort_address.cityid= params[:city][:cityid]
@resort_address.districtid= params[:district][:districtid]
@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
# @dummyObj2 = session[:resort_addressObj]
# @dummyObj2.save()
@resort_additionaldetail = ResortAddtionaldetail.new{}
#@resort_additionaldetail.resortid=-GHDnjl5KEZypvc4acjH5xA@public.gmane.org
@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()
session[:resort_additionaldetailObj] = @resort_additionaldetail
else
@stage=params[:stage].to_i
# @dummyObj3 = session[:resort_additionaldetailObj]
#@dummyObj3.save()
@resort_accomodation = ResortAccomodation.new{}
#@resort_accomodation.resortid=-GHDnjl5KEZzVC6+XVkywBQ@public.gmane.org
@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]
end
# @resort_basic.save()
# @resort_contactdetail.save()
# @resort_address.save()
# @resort_additionaldetail.save()
# @resort_accomodation.save()
@next_stage = @stage+1
#@wizard_data = session[:wizard_data]
render :template => ''wizard\\stage''+@next_stage.to_s
end
end
I enter the values in 5 forms but values not store corresponding table in
database.
please give me any suggestions.
Thanks
Balaji
On 12/4/08, balaji rajagopal
<balajiece.rajagopal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> Hi *Thorsten Müller*
> i got bugs:
> NoMethodError in WizardController#wizard
>
> You have a nil object when you didn''t expect it!
> You might have expected an instance of ActiveRecord::Base.
> The error occurred while evaluating nil.[]
>
> Please help me.
>
> Thanks and Regards
>
> Balaji
>
>
>
> On 12/4/08, balaji rajagopal
<balajiece.rajagopal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>>
>> Hi *Thorsten Müller*
>>
>> your guideness very helpful for me. i used the code but i got bugs.
>>
>> code
>>
>>
----------------------------------------------------------------------------------------------------------------------------------
>>
>> 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=-GHDnjl5KEZyez0ei9/+7zw@public.gmane.org
>>
>> @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=-GHDnjl5KEZwmDwch+3WvLQ@public.gmane.org
>>
>> @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=-GHDnjl5KEZypvc4acjH5xA@public.gmane.org
>>
>> @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=-GHDnjl5KEZzVC6+XVkywBQ@public.gmane.org
>>
>> @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 have 5 forms(5 stages) to create my rails application.
>>
>> 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.
>>
>>
>>
>> i used the code and not stored the value in database.im only doing this
>> rails project.
>> Please help me.
>>
>> Thanks and Regards
>>
>> Balaji
>>
>>
>> On 12/3/08, Thorsten Müller
<thorsten-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote:
>>>
>>>
>>> I do not really understand, what you are doing here, but:
>>>
>>> You are using "else if" without a condition several
times,
>>> beneath the fact that the correct ruby syntax is elsif
>>>
>>> Then Ruby would interpret the following line:
>>> @stage = params[:stage].to_i
>>> as condition and the outcome of this is most likely not
>>> what you would expect.
>>>
>>> And all those "end'' show too, that the structure is a
bit weird.
>>>
>>> I think, what you want to do would need something like this:
>>>
>>> def wizard
>>> if params[:stage].nil?
>>> ...
>>> elsif params[:stage].to_i == 1
>>> ...
>>> elsif params[:stage].to_i == 2
>>> ...
>>> else
>>> ...
>>> end
>>> render :template =>
''wizard\\stage''+@next_stage.to_s
>>> end
>>>
>>> >>>
>>>
>>
>
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
balaji rajagopal
2008-Dec-04 11:25 UTC
Re: Multiple Forms and Multiple tables +One Model +One Controller
*Hi Thorsten Müller * *In my rails application, im using five forms to save the corresponding 5 tables and 1st form using next button to 4th form.final form using create button.To click the create button to save the values in databases.* * please give any idea.... i can''t understand the bugs* *Please help me.............* *Thanks* *balaji* On 12/4/08, balaji rajagopal <balajiece.rajagopal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi *Thorsten Müller* > > I have 5 forms(5 stages) to create my rails application. > > 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. > > controller code > > ---------------------------------------------------------------------------------------------------------------------------- > > > 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 > # @dummyObj = session[:resort_basicObj] > > # @dummyObj.save() > > > @resort_contactdetail = ResortContactdetail.new{} > > # @resort_contactdetail.resortid=-GHDnjl5KEZyez0ei9/+7zw@public.gmane.org > > @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 <%23@resort_contactdetail.save>() > > session[:resort_contactdetailObj] = @resort_contactdetail > > elsif > #params[:stage].to_i ==2 > > @stage = params[:stage].to_i > # @dummyObj1 = session[:resort_contactdetailObj] > > # @dummyObj1.save() > > @resort_address = ResortAddress.new{} > > # @resort_address.resortid=-GHDnjl5KEZwmDwch+3WvLQ@public.gmane.org > > @resort_address.street= params[:street] > @resort_address.area= params[:area] > @resort_address.cityid= params[:city][:cityid] > @resort_address.districtid= params[:district][:districtid] > @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 > # @dummyObj2 = session[:resort_addressObj] > > # @dummyObj2.save() > > @resort_additionaldetail = ResortAddtionaldetail.new{} > > #@resort_additionaldetail.resortid=-GHDnjl5KEZypvc4acjH5xA@public.gmane.org<%23@resort_additionaldetail.resortid=-GHDnjl5KEZypvc4acjH5xA@public.gmane.org> > > @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() > > session[:resort_additionaldetailObj] = @resort_additionaldetail > > else > @stage=params[:stage].to_i > > > # @dummyObj3 = session[:resort_additionaldetailObj] > > #@dummyObj3.save <%23-GHDnjl5KEZz+S9nVO7k8dg@public.gmane.org>() > > @resort_accomodation = ResortAccomodation.new{} > > #@resort_accomodation.resortid=-GHDnjl5KEZzVC6+XVkywBQ@public.gmane.org<%23@resort_accomodation.resortid=-GHDnjl5KEZzVC6+XVkywBQ@public.gmane.org> > > @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] > > > > end > > # @resort_basic.save() > # @resort_contactdetail.save() > # @resort_address.save() > # @resort_additionaldetail.save() > # @resort_accomodation.save() > > @next_stage = @stage+1 > > #@wizard_data <%23@wizard_data> = session[:wizard_data] > > render :template => ''wizard\\stage''+@next_stage.to_s > end > end > > > > I enter the values in 5 forms but values not store corresponding table in > database. > please give me any suggestions. > > Thanks > Balaji > > On 12/4/08, balaji rajagopal <balajiece.rajagopal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> Hi *Thorsten Müller* >> i got bugs: >> NoMethodError in WizardController#wizard >> >> You have a nil object when you didn''t expect it! >> You might have expected an instance of ActiveRecord::Base. >> The error occurred while evaluating nil.[] >> >> Please help me. >> >> Thanks and Regards >> >> Balaji >> >> >> >> On 12/4/08, balaji rajagopal <balajiece.rajagopal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>> Hi *Thorsten Müller* >>> >>> your guideness very helpful for me. i used the code but i got bugs. >>> >>> code >>> >>> ---------------------------------------------------------------------------------------------------------------------------------- >>> >>> 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=-GHDnjl5KEZyez0ei9/+7zw@public.gmane.org >>> >>> @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=-GHDnjl5KEZwmDwch+3WvLQ@public.gmane.org >>> >>> @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=-GHDnjl5KEZypvc4acjH5xA@public.gmane.org >>> >>> @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=-GHDnjl5KEZzVC6+XVkywBQ@public.gmane.org >>> >>> @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 have 5 forms(5 stages) to create my rails application. >>> >>> 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. >>> >>> >>> >>> i used the code and not stored the value in database.im only doing this >>> rails project. >>> Please help me. >>> >>> Thanks and Regards >>> >>> Balaji >>> >>> >>> On 12/3/08, Thorsten Müller <thorsten-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote: >>>> >>>> >>>> I do not really understand, what you are doing here, but: >>>> >>>> You are using "else if" without a condition several times, >>>> beneath the fact that the correct ruby syntax is elsif >>>> >>>> Then Ruby would interpret the following line: >>>> @stage = params[:stage].to_i >>>> as condition and the outcome of this is most likely not >>>> what you would expect. >>>> >>>> And all those "end'' show too, that the structure is a bit weird. >>>> >>>> I think, what you want to do would need something like this: >>>> >>>> def wizard >>>> if params[:stage].nil? >>>> ... >>>> elsif params[:stage].to_i == 1 >>>> ... >>>> elsif params[:stage].to_i == 2 >>>> ... >>>> else >>>> ... >>>> end >>>> render :template => ''wizard\\stage''+@next_stage.to_s >>>> end >>>> >>>> >>>> >>>> >>> >> >--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
balaji rajagopal
2008-Dec-04 12:11 UTC
Re: Multiple Forms and Multiple tables +One Model +One Controller
*Hi Thorsten Müller * *In my rails application, im using five forms to save the corresponding 5 tables and 1st form using next button to 4th form.final form using create button.To click the create button to save the values in databases.* * please give any idea.... i can''t understand the bugs* *Please help me.............* *Thanks* *balaji* On 12/4/08, balaji rajagopal <balajiece.rajagopal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > *Hi Thorsten Müller * > *In my rails application, im using five forms to save the corresponding 5 > tables and 1st form using next button to 4th form.final form using create > button.To click the create button to save the values in databases.* > > * please give any idea.... i can''t understand the bugs* > > *Please help me.............* > > *Thanks* > *balaji* > > > On 12/4/08, balaji rajagopal <balajiece.rajagopal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> Hi *Thorsten Müller* >> >> I have 5 forms(5 stages) to create my rails application. >> >> 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. >> >> controller code >> >> ---------------------------------------------------------------------------------------------------------------------------- >> >> >> 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 >> # @dummyObj = session[:resort_basicObj] >> >> # @dummyObj.save() >> >> >> @resort_contactdetail = ResortContactdetail.new{} >> >> # @resort_contactdetail.resortid=-GHDnjl5KEZyez0ei9/+7zw@public.gmane.org >> >> @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 <%23@resort_contactdetail.save>() >> >> session[:resort_contactdetailObj] = @resort_contactdetail >> >> elsif >> #params[:stage].to_i ==2 >> >> @stage = params[:stage].to_i >> # @dummyObj1 = session[:resort_contactdetailObj] >> >> # @dummyObj1.save() >> >> @resort_address = ResortAddress.new{} >> >> # @resort_address.resortid=-GHDnjl5KEZwmDwch+3WvLQ@public.gmane.org >> >> @resort_address.street= params[:street] >> @resort_address.area= params[:area] >> @resort_address.cityid= params[:city][:cityid] >> @resort_address.districtid= params[:district][:districtid] >> @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 >> # @dummyObj2 = session[:resort_addressObj] >> >> # @dummyObj2.save() >> >> @resort_additionaldetail = ResortAddtionaldetail.new{} >> >> #@resort_additionaldetail.resortid=-GHDnjl5KEZypvc4acjH5xA@public.gmane.org<%23@resort_additionaldetail.resortid=-GHDnjl5KEZypvc4acjH5xA@public.gmane.org> >> >> @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() >> >> session[:resort_additionaldetailObj] = @resort_additionaldetail >> >> else >> @stage=params[:stage].to_i >> >> >> # @dummyObj3 = session[:resort_additionaldetailObj] >> >> #@dummyObj3.save <%23-GHDnjl5KEZz+S9nVO7k8dg@public.gmane.org>() >> >> @resort_accomodation = ResortAccomodation.new{} >> >> #@resort_accomodation.resortid=-GHDnjl5KEZzVC6+XVkywBQ@public.gmane.org<%23@resort_accomodation.resortid=-GHDnjl5KEZzVC6+XVkywBQ@public.gmane.org> >> >> @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] >> >> >> >> end >> >> # @resort_basic.save() >> # @resort_contactdetail.save() >> # @resort_address.save() >> # @resort_additionaldetail.save() >> # @resort_accomodation.save() >> >> @next_stage = @stage+1 >> >> #@wizard_data <%23@wizard_data> = session[:wizard_data] >> >> render :template => ''wizard\\stage''+@next_stage.to_s >> end >> end >> >> >> >> I enter the values in 5 forms but values not store corresponding table in >> database. >> please give me any suggestions. >> >> Thanks >> Balaji >> >> On 12/4/08, balaji rajagopal <balajiece.rajagopal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>> Hi *Thorsten Müller* >>> i got bugs: >>> NoMethodError in WizardController#wizard >>> >>> You have a nil object when you didn''t expect it! >>> You might have expected an instance of ActiveRecord::Base. >>> The error occurred while evaluating nil.[] >>> >>> Please help me. >>> >>> Thanks and Regards >>> >>> Balaji >>> >>> >>> >>> On 12/4/08, balaji rajagopal <balajiece.rajagopal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >>>> Hi *Thorsten Müller* >>>> >>>> your guideness very helpful for me. i used the code but i got bugs. >>>> >>>> code >>>> >>>> ---------------------------------------------------------------------------------------------------------------------------------- >>>> >>>> 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=-GHDnjl5KEZyez0ei9/+7zw@public.gmane.org >>>> >>>> @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=-GHDnjl5KEZwmDwch+3WvLQ@public.gmane.org >>>> >>>> @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=-GHDnjl5KEZypvc4acjH5xA@public.gmane.org >>>> >>>> @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=-GHDnjl5KEZzVC6+XVkywBQ@public.gmane.org >>>> >>>> @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 have 5 forms(5 stages) to create my rails application. >>>> >>>> 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. >>>> >>>> >>>> >>>> i used the code and not stored the value in database.im only doing this >>>> rails project. >>>> Please help me. >>>> >>>> Thanks and Regards >>>> >>>> Balaji >>>> >>>> >>>> On 12/3/08, Thorsten Müller <thorsten-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote: >>>>> >>>>> >>>>> I do not really understand, what you are doing here, but: >>>>> >>>>> You are using "else if" without a condition several times, >>>>> beneath the fact that the correct ruby syntax is elsif >>>>> >>>>> Then Ruby would interpret the following line: >>>>> @stage = params[:stage].to_i >>>>> as condition and the outcome of this is most likely not >>>>> what you would expect. >>>>> >>>>> And all those "end'' show too, that the structure is a bit weird. >>>>> >>>>> I think, what you want to do would need something like this: >>>>> >>>>> def wizard >>>>> if params[:stage].nil? >>>>> ... >>>>> elsif params[:stage].to_i == 1 >>>>> ... >>>>> elsif params[:stage].to_i == 2 >>>>> ... >>>>> else >>>>> ... >>>>> end >>>>> render :template => ''wizard\\stage''+@next_stage.to_s >>>>> end >>>>> >>>>> >>>>> >>>>> >>>> >>> >> >--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
balaji rajagopal
2008-Dec-05 08:00 UTC
Re: Multiple Forms and Multiple tables +One Model +One Controller
Hi i use various forms and one controller. view code <% form_tag :action => ''wizard'', :stage => @next_stage do %> controller code: def wizard if params[:stage].nil? ... elsif params[:stage].to_i == 1 ... elsif params[:stage].to_i == 2 ... elsif params[:stage].to_i == 3 ...... elsif params[:stage].to_i == 4 .............. else ... end render :template => ''wizard\\stage''+@next_stage.to_s end but i got error and first form values only saved in databases so please help me Thanks 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 -~----------~----~----~----~------~----~------~--~---
Peter De Berdt
2008-Dec-05 09:09 UTC
Re: Multiple Forms and Multiple tables +One Model +One Controller
On 05 Dec 2008, at 09:00, balaji rajagopal wrote:> i use various forms and one controller. > > view code > > <% form_tag :action => ''wizard'', :stage => @next_stage do %>---------------> controller code: > > def wizard > if params[:stage].nil? > ... > elsif params[:stage].to_i == 1 > ... > elsif params[:stage].to_i == 2 > ... > elsif params[:stage].to_i == 3 > ...... > elsif params[:stage].to_i == 4 > .............. > else > ... > endIf you see the above, you should seriously start thinking about giving up Ruby and going back to Applesoft BASIC. And even that would be insulting BASIC in a way.> render :template => ''wizard\\stage''+@next_stage.to_s > endWhy the double backslashes and where does that instance variable come out of all of a sudden? ''wizard/stage''+params[:stage] --------------- I''m really sorry to say, but your code has more wrong to it than right. You could also check out acts_as_wizard: http://github.com/Adkron/actsaswizard/tree/master Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
balaji rajagopal
2008-Dec-05 10:21 UTC
Re: Multiple Forms and Multiple tables +One Model +One Controller
Hi
I follow ur way and i used the above code but i got the bugs
can''t convert nil into String
code
---------------------------------------------------------------------------------
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
# @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
# @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.cityid= params[:city][:cityid]
@resort_address.districtid= params[:district][:districtid]
@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
# @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()
#session[:resort_additionaldetailObj] = @resort_additionaldetail
else params[:stage].to_i==4
# @stage=params[:stage].to_i
# @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_accomodation.save()
end
# @next_stage = @stage+1
#@wizard_data = session[:wizard_data]
# render :template => ''wizard\\stage''+@next_stage.to_s
render :template => ''wizard/stage''+params[:stage]
end
end
please help me
Thanks
balaji
On 12/5/08, Peter De Berdt
<peter.de.berdt-LPO8gxj9N8aZIoH1IeqzKA@public.gmane.org>
wrote:>
>
> On 05 Dec 2008, at 09:00, balaji rajagopal wrote:
>
> i use various forms and one controller.
>
> view code
>
> <% form_tag :action => ''wizard'', :stage =>
@next_stage do %>
>
>
>
>
>
> ---------------
>
> controller code:
>
> def wizard
> if params[:stage].nil?
> ...
> elsif params[:stage].to_i == 1
> ...
> elsif params[:stage].to_i == 2
> ...
> elsif params[:stage].to_i == 3
> ......
> elsif params[:stage].to_i == 4
> ..............
> else
> ...
> end
>
>
>
> If you see the above, you should seriously start thinking about giving up
> Ruby and going back to Applesoft BASIC. And even that would be insulting
> BASIC in a way.
>
> render :template => ''wizard\\stage''+@next_stage.to_s
> end
>
>
>
> Why the double backslashes and where does that instance variable come out
> of all of a sudden? ''wizard/stage''+params[:stage]
>
>
> ---------------
>
>
> I''m really sorry to say, but your code has more wrong to it than
right.
>
>
> You could also check out acts_as_wizard:
> http://github.com/Adkron/actsaswizard/tree/master
>
>
>
>
> Best regards
>
>
> Peter De Berdt
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Peter De Berdt
2008-Dec-05 10:31 UTC
Re: Multiple Forms and Multiple tables +One Model +One Controller
On 05 Dec 2008, at 11:21, balaji rajagopal wrote:> I follow ur way and i used the above code but i got the bugs > > can''t convert nil into StringWell, if an application gives you an error, it usually wants to say something. In this case it expected a string, and got a nil. You didn''t include what line it choked on, but I guess it''s the render one. It''s telling you that params[:stage] is nil, so you need to handle that. ''wizard/stage''+(params[:stage] || '''') And please please please, do yourself a favor, read some books on Rails first. There are some nice ones out there and most of them have a nice introduction to basic programming principles. Your code is just completely unmaintainable. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi i am new to rails.. can u explain me how do i store data into multiple table from one form.Explain me with sample code Also Explain me about association between tables..i studied many articles .but stil i am confuse. pls help me Thanks Durga -- 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 https://groups.google.com/groups/opt_out.