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

???
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.

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:

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

Hi Thorsten Müller

your guideness very helpful for me. i used the code but i got bugs.

code

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

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

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

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

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

i use various forms and one controller.

view code

<% form_tag :action => ‘wizard’, :stage => @next_stage do %>

Hi

I follow ur way and i used the above code but i got the bugs

can’t convert nil into String

code

Well, 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

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