why would I be getting this error after submitting my form? NoMethodError in EchantillonsController#create undefined method `call'' for nil:NilClass This is my create method in the controller: def create @echantillon = Echantillon.new(params[:echantillon]) @echantillon.set_eros_values respond_to do |format| if @echantillon.save if params[:echantillon][:vignette].blank? format.html { redirect_to(@echantillon) } format.xml { render :xml => @echantillon, :status => :created, :location => @echantillon } else render :action => "location" end else format.html { render :action => "new" } format.xml { render :xml => @echantillon.errors, :status => :unprocessable_entity } end end 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-/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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I think only two lines could cause this> @echantillon.set_eros_values> if @echantillon.saveWhich line does it say the error comes from in your output? You could write some Rails.logger.debug "Hi, this is the current status: #{@echantillon.inspect}" between every line and then watch your logs/development.log to see where exactly it breaks. I would guess on set_eros_values (whatever that function is supposed to do :) -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi> why would I be getting this error after submitting my form? > > NoMethodError in EchantillonsController#create > undefined method `call'' for nil:NilClass >Can''t say from this what caused error. Please paste in which line error happened and what is there on that line. Just a guess only> if params[:echantillon][:vignette].blank?instead of this please try unless params[:echantillon][:vignette] Sijo -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
The cause of this error is on this line:> else > render :action => "location" > endIt should be: else format.html {render :action => ''location''} end When using respond_to, the format of the response is required for any render or redirect_to methods. :) -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Seemingly Similar Threads
- gmaps4rails: undefined method `model_name' for NilClass:Class
- rspec controller test strange error: undefined method `call' for nil:NilClass
- undefined method `each'' for nil:NilClass with Ferret search
- Could not intern from yaml: undefined method `intern' for nil:NilClass
- Could not set file on ensure: undefined method `[]'' for nil:NilClass