我正在开发一个测试应用程序,其中赞成某事的人成为该用户的订阅者。影响控制器的模型中未初始化的常量
控制器:
def favorite_subscribe
@favorite_subscription = FavoriteSubscription.add_favorite_subscription(current_user, @user)
@user.favorite_subscriber_total = @user.favorite_subscriber_total + 1
@user.save
redirect_to :back, :notice => "Congratulations, you have favorited #{@user.username}."
end
型号:
def self.add_favorite_subscription(user, favorite_subscribe)
user.favorite_subscriptions.where(:subscribe_id => subscribe.id).first_or_create
end
# Remove the favorite of the user with the other user
def self.remove_favorite_subscription(user, favorite_subscribe)
user.favorite_subscriptions.where(:subscribe_id => subscribe.id).destroy_all
end
# Get the user with the subscription
def favorite_subscribe
User.find(subscribe_id)
end
我得到一个错误,它不能自动加载不变,并预计我的模型来定义它。如果任何人都可以提供帮助,那将会非常感激。
错误是在这里,比较遗憾的是:
Unable to autoload constant FavoriteSubscription, expected /home/jakxna360/rails/test/app/models/favorite_subscription.rb to define it
定义,其中是误差? –
发布错误日志。 – RAJ
并尝试包含模型和控制器定义。 –