Метод обновления Rails не работает: ActionView::MissingTemplate (отсутствуют элементы/обновление шаблона)

Ниже приведен мой метод обновления в 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

@item кажется успешно загруженным в журналах, после чего появляется Completed 500 Internal Server Error in 73ms:

Item Load (6.7ms)  SELECT  "items".* FROM "items" WHERE "items"."id" = ? ORDER BY "items"."created_at" DESC LIMIT 1  [["id", 30]]
Completed 500 Internal Server Error in 54ms

ActionView::MissingTemplate (Missing template items/update, application/update with {: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.

Кажется, что @item.update_attributes(item_params) ничего не делает. Любая подсказка, как это исправить?


person Community    schedule 05.07.2015    source источник
comment
Пожалуйста, обновите свой пост с полным журналом.   -  person Pavan    schedule 05.07.2015
comment
@Паван, это помогает?   -  person    schedule 05.07.2015


Ответы (1)


Это должно быть следующим:

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  # this line should be changed
    end
  end
person Rubyrider    schedule 05.07.2015
comment
Это ничего не меняет, все равно получаю ту же ошибку. - person ; 05.07.2015
comment
можно посмотреть лог вашего сервера? - person Rubyrider; 05.07.2015
comment
Похоже, Item.find не работает, я обновил вопрос. - person ; 05.07.2015