奇怪的错误:AbstractController :: ActionNotFound - Ruby on Rails

时间:2016-10-26 16:33:09

标签: ruby-on-rails ruby

好的,你们都来了!

错误是:

  

AbstractController :: ActionNotFound at / venues / 1动作'更新'   无法找到VenuesController

我也在VenuesController中的'destroy'动作中收到此错误。

我的GamesController中看起来完全相同的更新/销毁问题。

路线:

Rails.application.routes.draw do
 devise_for :users
 resources :events
 resources :venues 
 resources :games

 get "profiles/:id" => "profiles#show", as: :profile
 get "profiles" => "profiles#index"
 get "calendar" => 'profiles#calendar'


 root 'welcome#index'

 get 'about' => 'welcome#about'

 get 'contact' => 'welcome#contact'
end

My VenuesController是:

class VenuesController < ApplicationController
before_action :set_venue, only: [:show, :edit, :update, :destroy]
def new
  @venue = Venue.new
end

def show
end

def index
    @v = Venue.all
end

def edit
end

def create
    @venue = Venue.new(venue_params)

        respond_to do |format|
          if @venue.save
            format.html { redirect_to @venue, notice: 'Venue was successfully created.' }
          else
            format.html { render :new }
          end
        end
    end
end

def update
    respond_to do |format|
        if @venue.update(venue_params)
          format.html { redirect_to @venue, notice: 'Venue was successfully updated.' }
        else
          format.html { render :edit }
        end
    end
end

def destroy
    @venue.destroy
    respond_to do |format|
      format.html { redirect_to venues_url, notice: 'Venue was successfully destroyed.' }
    end
end

private

    def venue_params
        params.require(:venue).permit(:name, :address, :phone, :website, :venues_type)
    end
    def set_venue
        @venue = Venue.find(params[:id])
    end

我的场地视图_form.html.erb:

<%= form_for(@venue) do |f| %>
<% if @venue.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@venue.errors.count, "error") %> prohibited this venue from being saved:</h2>

      <ul>
        <% @venue.errors.full_messages.each do |message| %>
        <li><%= message %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :name %><br>
    <%= f.text_field :name %>
  </div>
  <div class="field">
    <%= f.label :address %><br>
    <%= f.text_field :address %>
  </div>
   <div class="field">
    <%= f.label :website %><br>
    <%= f.text_field :website %>
  </div>
  <div class="field">
    <%= f.label :venues_type %><br>
    <%= f.text_field :venues_type %>
  </div>
  <div class="field">
    <%= f.label :phone %><br>
    <%= f.text_field :phone, placeholder: "xxx-xxx-xxxx" %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

然后是我的筹码:

  

在2016-10-26 11:49:36 -0400为:: 1开始PATCH“/场地/ 1”

     

AbstractController :: ActionNotFound - 动作“更新”不可能   找到VenuesController:actionpack(5.0.0.1)   lib / abstract_controller / base.rb:121:在process' actionview (5.0.0.1) lib/action_view/rendering.rb:30:in进程'actionpack中   (5.0.0.1)lib / action_controller / metal.rb:190:在dispatch'
actionpack (5.0.0.1) lib/action_controller/metal.rb:262:in
dispatch'中   actionpack(5.0.0.1)lib / action_dispatch / routing / route_set.rb:50:in   dispatch' actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:32:in发送'actionpack   (5.0.0.1)lib / action_dispatch / journey / router.rb:39:在block in serve' actionpack (5.0.0.1) lib/action_dispatch/journey/router.rb:26:in 每个'actionpack(5.0.0.1)中   lib / action_dispatch / journey / router.rb:26:在serve' actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:725:in调用'   warden(1.2.6)lib / warden / manager.rb:35:in block in call' warden (1.2.6) lib/warden/manager.rb:34:in catch'warden(1.2.6)   lib / warden / manager.rb:34:in call' rack (2.0.1) lib/rack/etag.rb:25:in call'rack(2.0.1)   lib / rack / conditional_get.rb:38:in call' rack (2.0.1) lib/rack/head.rb:12:in call'rack(2.0.1)   lib / rack / session / abstract / id.rb:222:在context' rack (2.0.1) lib/rack/session/abstract/id.rb:216:in调用'actionpack(5.0.0.1)   lib / action_dispatch / middleware / cookies.rb:613:在call' activerecord (5.0.0.1) lib/active_record/migration.rb:552:in调用'actionpack中   (5.0.0.1)lib / action_dispatch / middleware / callbacks.rb:38:in block in call' activesupport (5.0.0.1) lib/active_support/callbacks.rb:97:in run_callbacks 'activesupport(5.0.0.1)   lib / active_support / callbacks.rb:750:在_run_call_callbacks'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:90:in
run_callbacks'actionpack(5.0.0.1)中   lib / action_dispatch / middleware / callbacks.rb:36:in call' actionpack (5.0.0.1) lib/action_dispatch/middleware/executor.rb:12:in call'
  actionpack(5.0.0.1)lib / action_dispatch / middleware / remote_ip.rb:79:in   call' better_errors (2.1.1) lib/better_errors/middleware.rb:84:in protected_app_call'beperior_errors(2.1.1)   lib / better_errors / middleware.rb:79:in better_errors_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:57:in
call'
  actionpack(5.0.0.1)
  lib / action_dispatch / middleware / debug_exceptions.rb:49:in call'
web-console (3.3.1) lib/web_console/middleware.rb:131:in
call_app'
  web-console(3.3.1)lib / web_console / middleware.rb:28:in block in call' web-console (3.3.1) lib/web_console/middleware.rb:18:in catch'web-console(3.3.1)lib / web_console / middleware.rb:18:in:   call' actionpack (5.0.0.1)
lib/action_dispatch/middleware/show_exceptions.rb:31:in
称之为'
  railties(5.0.0.1)lib / rails / rack / logger.rb:36:in call_app'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in
块中的电话'
  activesupport(5.0.0.1)lib / active_support / tagged_logging.rb:70:in   block in tagged' activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:26:in已标记为'activesupport   (5.0.0.1)lib / active_support / tagged_logging.rb:70:in tagged'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in
call'
  sprockets-rails(3.2.0)lib / sprockets / rails / quiet_assets.rb:13:in   call' actionpack (5.0.0.1) lib/action_dispatch/middleware/request_id.rb:24:in称'机架'   (2.0.1)lib / rack / method_override.rb:22:在call' rack (2.0.1) lib/rack/runtime.rb:22:in调用'activesupport(5.0.0.1)   LIB / active_support /缓存/策略/ local_cache_middleware.rb:28:在   call' actionpack (5.0.0.1) lib/action_dispatch/middleware/executor.rb:12:in调用'actionpack   (5.0.0.1)lib / action_dispatch / middleware / static.rb:136:在call'
rack (2.0.1) lib/rack/sendfile.rb:111:in
调用'railties(5.0.0.1)   lib / rails / engine.rb:522:在call' puma (3.6.0) lib/puma/configuration.rb:225:in调用'puma(3.6.0)   lib / puma / server.rb:578:in handle_request' puma (3.6.0) lib/puma/server.rb:415:in process_client'puma(3.6.0)   lib / puma / server.rb:275:在block in run' puma (3.6.0) lib/puma/thread_pool.rb:116:in调用'puma(3.6.0)   lib / puma / thread_pool.rb:116:在“spawn_thread中的块”

     

为:: 1启动POST“/ __ better_errors / 0c664909e8d5ec43 / variables”   2016-10-26 11:49:36 -0400

我完全被难过 - 任何想法/输入都非常感谢!谢谢!

1 个答案:

答案 0 :(得分:1)

您的场地控制器的创建方法有一个额外的end ,因此使其下方的所有其他内容都不在控制器之外。您实际上是在创建方法后关闭您的类。

所以从create方法定义中删除一个end,你没事。