given
class Dashboard::Superenalotto::CombinationsController < DashboardController
respond_to :html
def create
@superenalotto_combination = current_user.superenalotto_combinations.build(params[:superenalotto_combination])
flash[:notice] = 'Combination created.' if @superenalotto_combination.save
respond_with([:dashboard, @superenalotto_combination])
end
:dashboard is a namespaced route.
as per source documentation in
actionpack/lib/action_controller/metal/responder.rb from my
understanding this should be valid code; this will never render the
:new action template if validations fails because the resource is
an array.
in fact in the same file we have the method has_errors? which is
used to check if a record has passed validation or not, but using
the respond_with explained above in create action the resource is
an array, therefore will not respond_to?(:errors), let out .errors
method.
the resource that appears in has_errors? method in this case
is:
[:dashboard, #<SuperenalottoCombination id: nil, user_id: 2, ...]