With actions such as :show
and :edit
, I can just http GET them. But since the :update
action has no template, I can't issue a GET without it complaining about the missing template. That makes sense, so I tried to directly call @controller.update
in my test, but I get an error on the respond_to
block:
NoMethodError: undefined method `parameters' for nil:NilClass
How do I specify the requested format to be :html
? I am passing in a parameter hash for the model's attributes, FWIW. Thanks for any advice.
Edit: I since tried invoking @controller.update (after setting params[]) in the console and that error quoted above bubbled up from here: /actionpack-2.3.8/lib/action_controller/mime_responds.rb
I also tried PUT instead of GET, but still got "Missing Template update.erb".
Also, I managed to find out that this error of missing template is caused by having anything other than a redirect or render in the code block marked HERE:
respond_to do |format|
if @model.update_attributes(params[:model])
flash[:notice] = 'note!'
format.html { **HERE** }
...
I have a method call there that is just a conditional to redirect to the proper place. I can, in principle, understand why it might look for a template to render since it may not be aware that there is a redirect further downstream, but what I don't understand is how come my web application doesn't run into the same error as my functional test.