Rails update method not working: ActionView::MissingTemplate (Missing template items/update...) -
the following update method in items_controller
:
def update @item = item.find(params[:id]) if @item.update_attributes(item_params) flash[:success] = "item updated" redirect_to edit_item_path(@item) else render edit_item_path(@item) end end
the @item
seems loaded in logs, after completed 500 internal server error in 73ms
occurs:
item load (6.7ms) select "items".* "items" "items"."id" = ? order "items"."created_at" desc limit 1 [["id", 30]] completed 500 internal server error in 54ms actionview::missingtemplate (missing template items/update, application/update {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. searched in: * "/library/ruby/gems/2.0.0/gems/web-console-2.0.0.beta3/lib/action_dispatch/templates" * " # app route # " * "/library/ruby/gems/2.0.0/gems/web-console-2.0.0.beta3/app/views" ): actionview (4.2.0) lib/action_view/path_set.rb:46:in `find' actionview (4.2.0) lib/action_view/lookup_context.rb:121:in `find' actionview (4.2.0) lib/action_view/renderer/abstract_renderer.rb:18:in `find_template' etc.
it seems @item.update_attributes(item_params)
might not doing anything. clue how fix ?
this should following:
def update @item = item.find(params[:id]) if @item.update_attributes(item_params) flash[:success] = "item updated" redirect_to edit_item_path(@item) else render :edit # line should changed end end
Comments
Post a Comment