To store the combo box id value from one table another table in database+rails


#1

Hi.
I am new in ruby on rails…

Im using Two tables. one is Resortclass and another is Resortbasic.

Resortclass table using masterpage.View


Resort Classes

                

                

            
<%= paginating_links(@resort_classes) %>

    <% @resort_classes.each do |resort_class| %>
<% end %>
Resort Class Action
<%=h resort_class.resortclass %> <%= link_to 'Show', resort_class %> <%= link_to 'Edit', edit_resort_class_path (resort_class) %> <%= link_to 'Destroy', resort_class, :confirm => 'Are you sure?', :method => :delete %>
<%= button_to 'Add', new_resort_class_path,:class=>'myButton'%>

Resortclass is working and i need to the corresponding resortid value
and Im using five form and different tables and one controller is
Wizard controller

Resortbasic View Page

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



Add Resort Basic


<tr>
    <td>
       <b>Resort Class</b>
   </td>
   <td>
       <!--%=collection_select(:resortclassid, ResortClass.find

(:all),:id,:resortclass)%–>
<%=select(“resortclass”, “resortclassid”, ResortClass.find
(:all).collect {|p| [ p.resortclass, p.id ] })%>









Resort Name
        <%= text_field_tag :resortname %>
    </td>

</tr>
<tr>
    <td>
       <b>Resort Type</b>
   </td>
   <td>

       <!--%=f.collection_select(resort_basic.resorttypeid,

ResortType.find(:all),id,resorttype)%–>
<%=select(“resorttype”, “resorttypeid”, ResortType.find
(:all).collect {|p| [ p.resorttype, p.id ] })%>


Season


<%=select(“seasontype”, “seasontypeid”, Season.find
(:all).collect {|p| [ p.seasontype, p.id ] })%>

Website

<%= text_field_tag :website %>
   <td>

        <%= submit_tag "Next",:class =>'myButton' %>
 </td>

</tr>
<% end %>

Wizard controller

class WizardController < ApplicationController

def wizard
if params[:stage].nil?
@stage = 1
@resort_basic = ResortBasic.new {}

 @resort_basic.resortclassid=params[:resortclass];

 @resort_basic.resortname=params[:resortname];

 @resort_basic.resorttypeid=params[:resorttype];

 @resort_basic.seasonid=params[:seasontype];

 @resort_basic.website=params[:website];

 @resort_basic.save()

  session[:resort_basicObj] = @resort_basic   # Or whatever model

is storing your stuff

else

  @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()

end

@next_stage = @stage + 1

#@wizard_data = session[:wizard_data]

render :template => ‘wizard\stage’+@next_stage.to_s
end
end

But i got the resortname and website value and i didn’t get
resortclassid,resorttypeid value.

To store the combo box id value from one table another table in mysql
database+ruby on rails…
Please help me…

Thanks &Regards
Balaji


#2

On 1 Dec 2008, at 09:18, bala removed_email_address@domain.invalid wrote:

Check your logs to see what params are being submitted. Those combo
boxes will be in there, just not where you expect them

Fred


#3

Hi…
My Resortclass application is
Field =>id: resortclass
Value=>1:aaaaa
2:bbbbb in store in resortclasses table

My Resortbasic application is
Field =>id: resortclassid
Value=>1:1
2:1 in store in resortbasics table
I select 2nd value is bbbb but it is stored the id value is 1and
I select 2nd value is aaaa but it is stored the id value is 1
So i doubt error in wizard controller section

@resort_basic.resortclassid=params[:resortclass];

Please check and help me sir

Thanks &regards
Balaji


#4

On Dec 1, 10:35 am, “balaji rajagopal” removed_email_address@domain.invalid
wrote:

I select 2nd value is bbbb but it is stored the id value is 1and
I select 2nd value is aaaa but it is stored the id value is 1
So i doubt error in wizard controller section

Check again. I can assure you that resortclassid is not in params[:
resortclassid] but is somewhere else.
Don’t flail around blindly, use the debugger to inspect the params
hash and you’ll find out soon enough (or as a poor man’s alternative
use
<%= debug(params)%> in the view to display all the parameters received

Fred


#5

Hi

I used <%= debug(params)%> in the view to display the

!map:HashWithIndifferentAccess
controller: wizard
action: stage1

I can’t understand the error.Please anyone rectify the error.

Thanks &regards
Balaji


#6

On 1 Dec 2008, at 13:15, balaji rajagopal wrote:

Hi

I used <%= debug(params)%> in the view to display the

!map:HashWithIndifferentAccess
controller: wizard
action: stage1

I can’t understand the error.Please anyone rectify the error.

Just look in development.log. It shows you what params are received.
from that it should be clear.

Fred


#7

Hi
i got error…

Mysql::Error: #23000Column ‘resorttypeid’ cannot be null: INSERT INTO
resort_basics (resortclassid, resortname, resorttypeid,
seasonid, website) VALUES(1, 'mahapalipuram ', NULL, NULL,
www.mpm.com’)

RAILS_

please help me …

Thanks
balaji


#8

On Dec 2, 5:36 am, “balaji rajagopal” removed_email_address@domain.invalid
wrote:

The answer is right here. params[:resortname] exists, but params
[:resorttypeid] doesn’t - it’s inside params[:resorttype] (because
that’s what the select helper you’re using does)

Fred


#9

Hi…
Good Morning

I enter the values are mahapalipuram ,bbbb is equal to ID value is 2 but
i
got value 1,and hide 2 values so i got Null,Null,www.mpm.com

I can’t understand the error.So if any one help me…

Thanks
Balaji

ActiveRecord::StatementInvalid in WizardController#wizard

Mysql::Error: #23000Column ‘resorttypeid’ cannot be null: INSERT INTO
resort_basics (resortclassid, resortname, resorttypeid,
seasonid, website) VALUES(1, 'mahapalipuram ', NULL, NULL,
www.mpm.com’)

RAILS_ROOT: D:/RubyProjects/TestEcohols
Application Trace http://localhost:3000/wizard/wizard# | Framework
Tracehttp://localhost:3000/wizard/wizard#| Full
Trace http://localhost:3000/wizard/wizard#

D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:150:in
log' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:281:inexecute’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:156:in
insert_sql' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:291:ininsert_sql’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:44:in
insert' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:26:ininsert_with_query_dirty’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2272:in
create' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:226:increate_with_callbacks’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/timestamp.rb:29:in
create_with_timestamps' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2238:increate_or_update’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:213:in
create_or_update_with_callbacks' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1972:insave’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/validations.rb:934:in
save_with_validation' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:108:insave_with_transactions’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in
transaction' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:80:intransaction’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:100:in
transaction' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:108:insave_with_transactions’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:120:in
rollback_active_record_state!' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:108:insave_with_transactions’
app/controllers/wizard_controller.rb:42:in wizard' :1:instart’

D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:150:in
log' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:281:inexecute’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:156:in
insert_sql' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:291:ininsert_sql’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:44:in
insert' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:26:ininsert_with_query_dirty’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2272:in
create' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:226:increate_with_callbacks’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/timestamp.rb:29:in
create_with_timestamps' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2238:increate_or_update’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:213:in
create_or_update_with_callbacks' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1972:insave’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/validations.rb:934:in
save_with_validation' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:108:insave_with_transactions’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in
transaction' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:80:intransaction’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:100:in
transaction' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:108:insave_with_transactions’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:120:in
rollback_active_record_state!' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:108:insave_with_transactions’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:in
perform_action' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:incall_filters’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:689:in
perform_action_with_filters' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:inperform_action_with_benchmark’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/1.8/benchmark.rb:293:in measure' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:inperform_action_with_benchmark’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:in
perform_action_with_rescue' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:inperform_action_with_caching’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in
cache' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:incache’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:in
perform_action_with_caching' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:inprocess’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:in
process_with_filters' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:inprocess_with_session_management_support’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:in
process' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:inhandle_request’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in
dispatch' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:indispatch_cgi’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in
dispatch' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:112:inhandle_dispatch’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in
service' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/httpserver.rb:104:inservice’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/httpserver.rb:65:in run' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/server.rb:173:instart_thread’

D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:150:in
log' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:281:inexecute’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:156:in
insert_sql' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:291:ininsert_sql’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:44:in
insert' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:26:ininsert_with_query_dirty’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2272:in
create' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:226:increate_with_callbacks’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/timestamp.rb:29:in
create_with_timestamps' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2238:increate_or_update’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:213:in
create_or_update_with_callbacks' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1972:insave’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/validations.rb:934:in
save_with_validation' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:108:insave_with_transactions’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in
transaction' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:80:intransaction’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:100:in
transaction' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:108:insave_with_transactions’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:120:in
rollback_active_record_state!' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:108:insave_with_transactions’
app/controllers/wizard_controller.rb:42:in wizard' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:inperform_action’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:in
call_filters' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:689:inperform_action_with_filters’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in
perform_action_with_benchmark' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/1.8/benchmark.rb:293:inmeasure’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in
perform_action_with_benchmark' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:inperform_action_with_rescue’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:in
perform_action_with_caching' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:incache’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:in
cache' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:inperform_action_with_caching’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in
process' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:inprocess_with_filters’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:in
process_with_session_management_support' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:inprocess’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:in
handle_request' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:indispatch’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in
dispatch_cgi' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:indispatch’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:112:in
handle_dispatch' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:inservice’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/httpserver.rb:104:in
service' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/httpserver.rb:65:inrun’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/server.rb:173:in
start_thread' :1:instart’

Request

Parameters:

{“authenticity_token”=>“ad873f6fad6c67d5457b476d1130c5a966d74684”,
“resortname”=>"mahapalipuram ",
“resorttype”=>{“resorttypeid”=>“2”},
“resortclass”=>{“resortclassid”=>“2”},
“seasontype”=>{“seasontypeid”=>“2”},
“website”=>“www.mpm.com”,
“commit”=>“Next”}

Show session dump http://localhost:3000/wizard/wizard#


:resort_basicObj: &id001 !ruby/object:ResortBasic
new_record: false
attributes:
resortclassid: !map:HashWithIndifferentAccess
resortclassid: !str 2
resorttypeid: !map:HashWithIndifferentAccess
resorttypeid: !str 2
resortname: mahapalipuram resort
seasonid: !map:HashWithIndifferentAccess
seasontypeid: !str 2
id: 1
website: www.mpm.com
errors: !ruby/object:ActiveRecord::Errors
errors: {}
base: *id001
attributes_cache: {}
:csrf_id: 4da1a45d719ec0423735f506d5aa6c98
flash: !map:ActionController::Flash::FlashHash {}

Response

Headers:

{“Cache-Control”=>“no-cache”,
“cookie”=>[]}


#10

On 2 Dec 2008, at 10:18, balaji rajagopal wrote:

Combo box coding in controller

  1. @resort_basic.resortclassid=params[:resortclass];

got error in 3rd code :id value stored in 1 but id value is not
store 2

correct id value is 2…

This is really super basic ruby - you’ll be wasting a lot of time if
you don’t go back and read the basics. It should be obvious from
what’s below that
params[:resortclass][:resorttypeid]

grabs the right parameter id.
You’re also creating rather more work for your self than you need. Get
it right and you can just do resort_basic = ResortBasic.new
params[:resort_basic].
http://guides.rubyonrails.org/form_helpers.html has some details on
that, also see the documentation for form_for etc…

Fred


#11

Hi

Textbox coding in controller

@resort_basic.resortname=params[:resortname];

is working well and i got the value…

Combo box coding in controller

  1. @resort_basic.resortclass[resortclassid]=params[:resortclass];

got error in 1st code : undefined method `resortclass’ for
#ResortBasic:0x5ba21a

  1. @resort_basic.resortclassid=params[:resortclass[resortclassid]];

got error in 2nd code :undefined local variable
or method`resortclassid’for #WizardController:0x7310db

  1. @resort_basic.resortclassid=params[:resortclass];

got error in 3rd code :id value stored in 1 but id value is not store 2

correct id value is 2…

so please help me sir…

Thanks &Regards
balaji.R


#12

Hi Frederick C.
Good Evening…

Your Guideness very useful for me and I got the combo box id value…

Thank you sir…

Thanks & Regards
Balaji.R


#13

Hi Frederick C.

I use one controller+five tables+one detailed form( it includes five
form or
page).First page enter the data and click next button(get the data using
session) and final to click save button to store all data to
corresponding
table.

But controller page 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

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

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

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.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=@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
end
end
end
end
end

I got the error:Template missing …

No increment stage…and please help me…

Thanks &regards

Balaji.R


#14

Hi Frederick C.
Good Morning

I got the error:Template missing …

No increment stage…and please help me…

Thanks &regards

Balaji.R


#15

Hi Frederick C.
Good Morning

use one controller+five tables+one detailed form( it includes five form
or
page).First page enter the data and click next button(get the data using
session) and final to click save button to store all data to
corresponding
table.

Please give idea and help me…

Thanks
Balaji


#16

Hi Frederick C.

use one controller+five tables+one detailed form( it includes five form
or
page).First page enter the data and click next button(get the data using
session) and final to click save button to store all data to
corresponding
table. Please give an example code

Please give idea and help me…

Thanks
Balaji


#17

Hi Frederick C.

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.

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=@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.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 ==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()

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 = session[:wizard_data]

render :template => ‘wizard\stage’+@next_stage.to_s
end
end

i enter the values but not stored and 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.[]

RAILS_ROOT: D:/RubyProjects/TestEcohols
Application Trace http://localhost:3000/wizard/wizard?stage=2# |
Framework
Trace http://localhost:3000/wizard/wizard?stage=2# | Full
Tracehttp://localhost:3000/wizard/wizard?stage=2#

app/controllers/wizard_controller.rb:58:in wizard' :1:instart’

D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:in
perform_action' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:incall_filters’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:689:in
perform_action_with_filters' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:inperform_action_with_benchmark’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/1.8/benchmark.rb:293:in measure' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:inperform_action_with_benchmark’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:in
perform_action_with_rescue' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:inperform_action_with_caching’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in
cache' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:incache’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:in
perform_action_with_caching' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:inprocess’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:in
process_with_filters' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:inprocess_with_session_management_support’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:in
process' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:inhandle_request’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in
dispatch' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:indispatch_cgi’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in
dispatch' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:112:inhandle_dispatch’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in
service' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/httpserver.rb:104:inservice’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/httpserver.rb:65:in run' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/server.rb:173:instart_thread’

app/controllers/wizard_controller.rb:58:in wizard' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:inperform_action’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:in
call_filters' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:689:inperform_action_with_filters’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in
perform_action_with_benchmark' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/1.8/benchmark.rb:293:inmeasure’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in
perform_action_with_benchmark' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:inperform_action_with_rescue’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:in
perform_action_with_caching' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:incache’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:in
cache' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:inperform_action_with_caching’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in
process' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:inprocess_with_filters’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:in
process_with_session_management_support' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:inprocess’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:in
handle_request' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:indispatch’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in
dispatch_cgi' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:indispatch’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:112:in
handle_dispatch' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:inservice’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/httpserver.rb:104:in
service' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/httpserver.rb:65:inrun’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/server.rb:173:in
start_thread' :1:instart’

Request

Parameters:

{“authenticity_token”=>“09ab9bb40356d304564035a6b4a160d49dfccd66”,
“firstname”=>“balaji”,
“lastname”=>“raja”,
“designation”=>“director”,
“email_id”=>“removed_email_address@domain.invalid”,
“mobile”=>“999946936”,
“telephone1”=>“4586854756”,
“telephone2”=>“458269556”,
“fax”=>“458256259”,
“commit”=>“Next”,
“stage”=>“2”}

Please give idea and help me…

Thanks
Balaji


#18

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=@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
@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]

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


#19

On 4 Dec 2008, at 09:01, balaji rajagopal wrote:

“telephone1”=>“4586854756”,
“telephone2”=>“458269556”,
“fax”=>“458256259”,
“commit”=>“Next”,
“stage”=>“2”}

Stage 2 tries to access (among other things) params[:district]
[:districtid] which is not one of the parameters submitted.

Fred


#20

Hi Frederick C.
**
im using the same code and final change code(remove the hide )

end
**
@resort_basic.save()
@resort_contactdetail.save()
@resort_address.save()
@resort_additionaldetail.save()
@resort_accomodation.save()

I got the 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.save

RAILS_ROOT: D:/RubyProjects/TestEcohols
Application Trace http://localhost:3000/wizard/wizard?stage=2# |
Framework
Trace http://localhost:3000/wizard/wizard?stage=2# | Full
Tracehttp://localhost:3000/wizard/wizard?stage=2#

app/controllers/wizard_controller.rb:117:in wizard' :1:instart’

D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:in
perform_action' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:incall_filters’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:689:in
perform_action_with_filters' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:inperform_action_with_benchmark’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/1.8/benchmark.rb:293:in measure' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:inperform_action_with_benchmark’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:in
perform_action_with_rescue' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:inperform_action_with_caching’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in
cache' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:incache’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:in
perform_action_with_caching' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:inprocess’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:in
process_with_filters' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:inprocess_with_session_management_support’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:in
process' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:inhandle_request’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in
dispatch' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:indispatch_cgi’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in
dispatch' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:112:inhandle_dispatch’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in
service' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/httpserver.rb:104:inservice’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/httpserver.rb:65:in run' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/server.rb:173:instart_thread’

app/controllers/wizard_controller.rb:117:in wizard' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:inperform_action’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:in
call_filters' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:689:inperform_action_with_filters’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in
perform_action_with_benchmark' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/1.8/benchmark.rb:293:inmeasure’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in
perform_action_with_benchmark' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:inperform_action_with_rescue’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:in
perform_action_with_caching' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:incache’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:in
cache' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:inperform_action_with_caching’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in
process' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:inprocess_with_filters’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:in
process_with_session_management_support' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:inprocess’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:in
handle_request' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:indispatch’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in
dispatch_cgi' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:indispatch’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:112:in
handle_dispatch' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:inservice’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/httpserver.rb:104:in
service' D:/Program Files/NetBeans 6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/httpserver.rb:65:inrun’
D:/Program Files/NetBeans
6.1/ruby2/jruby-1.1/lib/ruby/1.8/webrick/server.rb:173:in
start_thread' :1:instart’

Request

Parameters:

{“authenticity_token”=>“09ab9bb40356d304564035a6b4a160d49dfccd66”,
“firstname”=>“raja”,
“lastname”=>“ram”,
“designation”=>“director”,
“email_id”=>“removed_email_address@domain.invalid”,
“mobile”=>“9458289369”,
“telephone1”=>“41252452”,
“telephone2”=>“452865858”,
“fax”=>“425828825”,
“commit”=>“Next”,
“stage”=>“2”}

I can’t understand the bugs.So please help me Frederick C.

Thanks & Regards

Balaji