Bontina Chen
2007-Jan-11 08:23 UTC
nil object while the required parameter are in the request
I''m having an application as follows. I have all the parameters for as object appended in the url. And there is an action in the controller like this def newlet render :layout=> false @product = Product.new if request.get? @product.title= params[:title] @product.description = params[:description] @product.primary_link = params[:primary_link] @product.image_url1 = params[:image_url1] @product.primary_price = params[:primary_price] end end And the url looks like http://example.com/controllername/newlet?title=aaaa&description=bbbb&primary_link=cccc&image_url=dddd&primary_price=1220 And the corresponding view <form action="/admin/newlet" method="get"> <!--[form:product]--> <p><label for="product_title">Title</label><br/> <input id="product_title" name="title" size="30" type="text" value="<%=-vsVTqSbophcJ9d+TTMi85w@public.gmane.org%>" /></p> <p><label for="product_primary_link">Primary link</label><br/> <input id="product_primary_link" name="primary_link" size="30" type="text" value="<%=-vsVTqSbophe6jFLNHf1bMg@public.gmane.org_link%>" /></p> <p><label for="product_description">Description</label><br/> <textarea cols="40" id="product_description" name="description" value="<%=-vsVTqSbophff2rX7sHnDGxaQ6ez/PmRj@public.gmane.org%>" rows="20"></textarea></p> <p><label for="product_image_url1">Image url1</label><br/> <input id="product_image_url1" name="image_url1" size="30" type="text" value="<%=-vsVTqSbopheX0zQIGAV3lg@public.gmane.org_url1%>" /></p> <p><label for="product_primary_price">Primary price</label><br/> <input id="product_primary_price" name="primary_price" value="<%=-vsVTqSbophe6jFLNHf1bMg@public.gmane.org_price%>" size="30" type="text" /></p> <!--[eoform:product]--> <input name="commit" type="submit" value="Create" /> </form> But the error message NoMethodError in Admin#newlet Showing app/views/admin/_autoform.rhtml where line #8 raised: You have a nil object when you didn''t expect it! The error occured while evaluating nil.title Extracted source (around line #8): 5: 6: <!--[form:product]--> 7: <p><label for="product_title">Title</label><br/> 8: <input id="product_title" name="title" size="30" type="text" value="<%=-vsVTqSbophcJ9d+TTMi85w@public.gmane.org%>" /></p> 9: 10: <p><label for="product_primary_link">Primary link</label><br/> 11: <input id="product_primary_link" name="primary_link" size="30" type="text" value="<%=-vsVTqSbophe6jFLNHf1bMg@public.gmane.org_link%>" /></p> Trace of template inclusion: /app/views/admin/newlet.rhtml RAILS_ROOT: C:/INSTAN~1/rails_apps/test/config/.. Application Trace | Framework Trace | Full Trace #{RAILS_ROOT}/app/views/admin/_autoform.rhtml:8:in `_run_rhtml_admin__autoform'' #{RAILS_ROOT}/app/views/admin/newlet.rhtml:5:in `_run_rhtml_admin_newlet'' #{RAILS_ROOT}/app/controllers/admin_controller.rb:37:in `newlet'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in `send'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in `compile_and_render_template'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:292:in `render_template'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:251:in `render_file'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:266:in `render'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/partials.rb:59:in `render_partial'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:29:in `benchmark'' C:/INSTAN~1/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'' C:/INSTAN~1/ruby/lib/ruby/1.8/benchmark.rb:307:in `realtime'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:29:in `benchmark'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/partials.rb:58:in `render_partial'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:278:in `render'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in `send'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in `compile_and_render_template'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:292:in `render_template'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:251:in `render_file'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:726:in `render_file'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:695:in `render_with_no_layout'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/layout.rb:253:in `render_without_benchmark'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:53:in `render'' C:/INSTAN~1/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:53:in `render'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in `send'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in `perform_action_without_filters'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' C:/INSTAN~1/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in `perform_action'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in `send'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in `process_without_filters'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in `process_without_session_management_support'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in `process'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in `dispatch'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/rails.rb:73:in `process'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:551:in `process_client'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:550:in `each'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:550:in `process_client'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in `run'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in `initialize'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in `new'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in `run'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:625:in `initialize'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:625:in `new'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:625:in `run'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:956:in `run'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:955:in `each'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:955:in `run'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/bin/mongrel_rails:127:in `run'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/command.rb:199:in `run'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/bin/mongrel_rails:235 C:/INSTAN~1/ruby/bin/mongrel_rails:18:in `load'' C:/INSTAN~1/ruby/bin/mongrel_rails:18 #{RAILS_ROOT}/app/views/admin/_autoform.rhtml:8:in `_run_rhtml_admin__autoform'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in `send'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in `compile_and_render_template'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:292:in `render_template'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:251:in `render_file'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:266:in `render'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/partials.rb:59:in `render_partial'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:29:in `benchmark'' C:/INSTAN~1/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'' C:/INSTAN~1/ruby/lib/ruby/1.8/benchmark.rb:307:in `realtime'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:29:in `benchmark'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/partials.rb:58:in `render_partial'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:278:in `render'' #{RAILS_ROOT}/app/views/admin/newlet.rhtml:5:in `_run_rhtml_admin_newlet'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in `send'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in `compile_and_render_template'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:292:in `render_template'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:251:in `render_file'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:726:in `render_file'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:695:in `render_with_no_layout'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/layout.rb:253:in `render_without_benchmark'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:53:in `render'' C:/INSTAN~1/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:53:in `render'' #{RAILS_ROOT}/app/controllers/admin_controller.rb:37:in `newlet'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in `send'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in `perform_action_without_filters'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' C:/INSTAN~1/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in `perform_action'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in `send'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in `process_without_filters'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in `process_without_session_management_support'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in `process'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in `dispatch'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/rails.rb:73:in `process'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:551:in `process_client'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:550:in `each'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:550:in `process_client'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in `run'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in `initialize'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in `new'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in `run'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:625:in `initialize'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:625:in `new'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:625:in `run'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:956:in `run'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:955:in `each'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:955:in `run'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/bin/mongrel_rails:127:in `run'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/command.rb:199:in `run'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/bin/mongrel_rails:235 C:/INSTAN~1/ruby/bin/mongrel_rails:18:in `load'' C:/INSTAN~1/ruby/bin/mongrel_rails:18 Request Parameters: {"title"=>"Yatego_Merino_Soft_Stringbody.jpg (JPEG \345\234\226\347\211\207\357\274\214400x527 \345\203\217\347\264\240)", "primary_link"=>"http://www9.yatego.com/images/450121e567d499.5/Yatego_Merino_Soft_Stringbody.jpg", "primary_price"=>"2000", "description"=>"hlghghkgf", "image_url1"=>"http://www9.yatego.com/images/450121e567d499.5/Yatego_Merino_Soft_Stringbody.jpg"} I can see the request contains all the parameter needed. And I''ve also validated each parameter. No idea what could go wrong with this. -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Stephan Wehner
2007-Jan-11 09:04 UTC
Re: nil object while the required parameter are in the reque
Bontina Chen wrote:> I''m having an application as follows. > I have all the parameters for as object appended in the url. > And there is an action in the controller like this > > def newlet# Move this line to the end of method newlet> render :layout=> false > @product = Product.new > > if request.get? > @product.title= params[:title] > @product.description = params[:description] > @product.primary_link = params[:primary_link] > @product.image_url1 = params[:image_url1] > @product.primary_price = params[:primary_price] > > end# Here render :layout=> false> end >Stephan -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Stephan Wehner wrote:> Bontina Chen wrote: >> I''m having an application as follows. >> I have all the parameters for as object appended in the url. >> And there is an action in the controller like this >> >> def newlet > > # Move this line to the end of method newlet > >> render :layout=> false >> @product = Product.new >> >> if request.get? >> @product.title= params[:title] >> @product.description = params[:description] >> @product.primary_link = params[:primary_link] >> @product.image_url1 = params[:image_url1] >> @product.primary_price = params[:primary_price] >> >> end > > # Here > > render :layout=> false > > >> end >> > > StephanIt works!!! THANKS A LOT But I have two create button at the bottom. When I remove <input name="commit" type="submit" value="Create" /> They are all gone. I suppose there should be one left. -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Stephan Wehner
2007-Jan-11 09:47 UTC
Re: nil object while the required parameter are in the reque
> But I have two create button at the bottom. > When I remove <input name="commit" type="submit" value="Create" />Just to make sure, the create buttons both say "Create" ? Try changing the one "Create" that you see to "Create2" and see what happens. I don''t recall the Windows equivalent of grep, this might help too: grep Create app/*/* app/*/*/* Also it seems you should be using method="POST", not "GET" for your form. See also http://www.theserverside.com/tt/articles/article.tss?l=RedirectAfterPost about redirecting in response to POSTs. Stephan -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Bontina Chen
2007-Jan-11 12:58 UTC
Re: nil object while the required parameter are in the reque
Stephan Wehner wrote:>> But I have two create button at the bottom. >> When I remove <input name="commit" type="submit" value="Create" /> > > Just to make sure, the create buttons both say "Create" ? > > Try changing the one "Create" that you see to "Create2" and see what > happens. > > I don''t recall the Windows equivalent of grep, this might help too: > > grep Create app/*/* app/*/*/* > > Also it seems you should be using method="POST", not "GET" for your > form. > See also > > http://www.theserverside.com/tt/articles/article.tss?l=RedirectAfterPost > > about redirecting in response to POSTs. > > StephanThanks for the reference. I''m doing this in two stages. I use get to fill data in the form column. And post when user makes sure this is what the want to summit. I figured out the difference of the two create button. Only one of them is really functioning. this one <input name="commit" type="submit" value="Create" /> But I found the data in the @product are all flushed out through this action. def create @product = Product @product.user_id = session[:user_id] @product.created_at = Time.now if @product.save flash[:notice] = ''Product was successfully created.'' redirect_to :action => ''list'' else render :action => ''new'' end end Anything I can do to keep the data? Many thanks -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Stephan Wehner
2007-Jan-11 16:01 UTC
Re: nil object while the required parameter are in the reque
> > But I found the data in the @product are all flushed out through this > action. > > def create# You seem to mean @product = Product.new(params[:product]) # instead of just Product.> @product = Product > @product.user_id = session[:user_id] > @product.created_at = Time.now > > if @product.save > flash[:notice] = ''Product was successfully created.'' > redirect_to :action => ''list'' > > else > render :action => ''new'' > > end > end > > Anything I can do to keep the data? > > Many thanks-- 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-/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 -~----------~----~----~----~------~----~------~--~---
Bontina Chen
2007-Jan-12 01:29 UTC
Re: nil object while the required parameter are in the reque
That''s a mis-paste sorry. I fixed the problem. Thank you so much for all the help. -- 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-/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 -~----------~----~----~----~------~----~------~--~---