gpt4 book ai didi

ruby-on-rails - 路由错误未初始化的常量聚会

转载 作者:行者123 更新时间:2023-12-03 08:39:19 24 4
gpt4 key购买 nike

我目前因未初始化的常量聚会而陷入路由错误

class MeetupsController < ApplicationController
before_action :set_meetup, only: [:edit, :update, :destroy]
def create
@meetup = Meetup.new(host: current_user)
@meetup.save
redirect_to meetup_create_path(Wicked::FIRST_STEP, meetup_id: @meetup.id)
end
end
这是我的MeetupsController内部的create函数,您可以看到 Controller 名称为复数,文件名为“meetups_controller.rb”
以下是我的routes.rb
Rails.application.routes.draw do
devise_for :users
resources :users
resources :meetups, except: [:show] do
resources :create, controller: 'meetups/setup'
resources :participations, only: [:new]
member do
get "create/review", to: 'meetups/setup#review'
end
end

root to: 'pages#home'
get 'join_meetup', to: 'pages#join_meetup'
get 'events', to: 'pages#events'
get 'landing', to: 'pages#landing'
end
任何帮助将不胜感激。

最佳答案

错误跟踪将更有用。
但是查看路由文件中的resources :create, controller: 'meetups/setup',我可能会猜到Rails应用程序期望将命名空间 Controller 作为Meetups::SetupController
因此,您需要相应地更改 Controller 。您需要创建一个命名空间的 Controller ,也可以是一个作用域的 Controller 。
引用:http://guides.rubyonrails.org/routing.html#controller-namespaces-and-routing

关于ruby-on-rails - 路由错误未初始化的常量聚会,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63246735/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com