在我的rails应用程序中尝试创建新的user_subscription时,我收到以下错误。
无法自动加载常量UserSubscriptionsController,预期/Users/antarrbyrd/dev/rail-app/app/controllers/user_subscriptions_controller.rb来定义它
class UserSubsciptionController < ApplicationController
def create
user_id = params[:user_id]
app_id = params[:app_id]
UserSubsciption.find_or_create_by(user_id: user_id, app_id: app_id)
redirect_to root_path
end
end
get 'user_subcriptions/create/:user_id/:app_id', to: 'user_subscriptions#create', as: 'create_subscription'
class UserSubscription < ActiveRecord::Base
belongs_to :user
belongs_to :app
end
<h5>
<%= link_to 'Watch this app', create_subscription_path(session[:user_id], app.id) %>
</h5>
本地变量
from_mod Object
const_name :UserSubscriptionsController
qualified_name "UserSubscriptionsController"
path_suffix "user_subscriptions_controller"
file_path "/Users/antarrbyrd/dev/.../app/controllers/user_subscriptions_controller.rb"
expanded "/Users/antarrbyrd/dev/.../app/controllers/user_subscriptions_controller"
mod nil
parent nil
e nil
答案 0 :(得分:1)
在app / controllers / user_subscriptions_controller.b文件中,将班级UserSubscriptionsController
重命名为UserSubsciptionsController