2015-07-05 2 views
1

Ниже мой метод обновления в items_controller:Rails метод обновления не работает: ActionView :: MissingTemplate (Отсутствует шаблон пунктов/обновление ...)

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) не может делать ничего. Любой ключ, как это исправить?

+0

Пожалуйста, обновите ваш пост с полным бревном. – Pavan

+0

@Pavan это помогает? –

ответ

0

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

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 
+0

Это ничего не меняет, все равно получайте ту же ошибку. –

+0

Могу я увидеть ваш журнал сервера? – Rubyrider

+0

Похоже, что 'Item.find' не работает, я обновил quesiton. –

 Смежные вопросы

  • Нет связанных вопросов^_^