Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6546055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:39:40+00:00 2026-05-25T11:39:40+00:00

I have some kind of problem when adding models to my Ruby on Rails

  • 0

I have some kind of problem when adding models to my Ruby on Rails project.
I have a cute cople of controller and model, but the controller cannot access the model because the symbol seems to be… undefined.

So it seems I don’t understand AT ALL how Rails chooses which classes to load and which not to load.

Here’s my model file (and YES, I know, I should have a file for each model. And I did. But I’ve been trying everything to make it work, and currently I just have one) :

class Feed
  include Mongoid::Document
  field       :name,        :type => String
  field       :description, :type => String
  field       :public,      :type => Boolean, :default => false
  has_many    :posts, :class_name => 'FeedPost'
  embedded_in :user

  def isSubscribed? user
    res = user.feedsubscribtions.where :userId => self.user.id, :feedId => self.id
    res.count > 0
  end
end

class Feedsubscribtion
  include Mongoid::Document
  field       :userId, :type => String
  field       :feedId, :type => String
  embedded_in :user

  def Owner
    user = User.where :id => self.userId
    if user != nil then user.first else nil end
  end

  def Feed
    user = Owner()
    feed = user.feeds.where :id => self.feedId
    if feed != nil then feed.first else nil end
  end
end

Everything with the Feed model and controllers work just swell. I just have this problem with FeedControllers and a few other classes, that doesn’t have associated controllers, and just don’t seem to even exist in my Rails project as far as the controllers are concerned.

And then I have my feedsubscribtion_controller :

class FeedsubscribtionsController < ApplicationController
  has_to_be_connected

  def create
    if session[:user_id] != params[:id]
      @self        = CurrentUser()
      subscribtion = Feedsubscribtion.new :userId => params[:id], :feedId => params[:feed]
      @self.feedsubscribtions |=  [ subscribtion ]
      render json: { success: @self.save(validate: false), feed: params[:feed] }
    end
  end

  def destroy
    if session[:user_id] != params[:id]
      @self    = CurrentUser()
      uid, fid = BSON::ObjectId.new(params[:id]), BSON::ObjectId.new(params[:feed])
      @feed    = @self.feedsubscribtions.where :userId => uid, :fid => fid
      if @feed.count > 0
        @feed.first.delete
    @self.save(validate: false)
      end
    end
  end
end

I’ve been trying to make a workaround, where a method of Feed would return me the instance of Feedsubscribtion. It worked for “create” : not for “destroy”. Because it seems Mongoid::Document.where tries to use FeedSubscribtion. And fails, of course.

What’s happening to me ?
Why the hell Rails doesn’t make Feedsubscribtion available outside of its own file ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:39:41+00:00Added an answer on May 25, 2026 at 11:39 am

    First, rename your model to FeedSubscription, then place it in a file at app/models/feed_subscription.rb. Then change the references at your controllers to access the FeedSubscription class and rename your methods Owner and Feed and CurrentUser, as methods should always be defined in lowercase in Ruby.

    When you define something starting with an uppercase in Ruby it makes it a constant.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some kind of problem with jQuery selectors. Let's say i want to
Here's a problem. Developers have some kind of a task (develop certain feature), which
I have a problem: imagine I have a plugin-based system. I need some kind
I want to have some kind of bounce effect in my animation plugin but
I have only installed Ruby1.9 on my machine. Have some kind of problems with
I have some kind of test data and want to create a unit test
Most program languages have some kind of exception handling; some languages have return codes,
I want to have some kind of single list that is initialized in a
Is it possible in Eclipse to have some kind of packages (sets of projects)
Is there a way to have some kind of default constructor (like a C++

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.