铁无法自动加载控制器

时间:2015-03-09 20:21:25

标签: ruby-on-rails ruby ruby-on-rails-4.1

在我的rails应用程序中尝试创建新的user_subscription时,我收到以下错误。

无法自动加载常量UserSubscriptionsController,预期/Users/antarrbyrd/dev/rail-app/app/controllers/user_subscriptions_controller.rb来定义它

的应用程序/控制器/ user_subscriptions_controller.b

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

配置/ routes.rb中

  get 'user_subcriptions/create/:user_id/:app_id', to: 'user_subscriptions#create', as: 'create_subscription'

的应用程序/模型/ user_subscription.rb

class UserSubscription < ActiveRecord::Base
  belongs_to :user
  belongs_to :app
end

的应用程序/视图/应用/ _full.html.erb

<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

1 个答案:

答案 0 :(得分:1)

在app / controllers / user_subscriptions_controller.b文件中,将班级UserSubscriptionsController重命名为UserSubsciptionsController