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

  • SEARCH
  • Home
  • 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 8781693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:22:14+00:00 2026-06-13T20:22:14+00:00

I have in my application a few controllers that i want to use as

  • 0

I have in my application a few controllers that i want to use as a api. In this api i need to use versioning.

in my routes.rb i`m using this:

require 'api_constraints'

(…)

  scope '/:target/:version', :module => :api, :constraints => { :version => /[0-z\.]+/ } , :defaults => { :format => 'json' } do
    scope :module => :v1, :constraints => ApiConstraints.new(:version => 1, :default => true) do
      match '/list' => 'sample#list'
    end
  end

my api_constraints.rb:

class ApiConstraints

  def initialize(options)
    @version = options[:version]
    @default = options[:default]
  end

  def matches?(req)
    @default || req.headers['Accept'].include?("application/waytaxi.api.v#{@version}")
  end

  def self.version
    @version
  end

end

in my SampleController.rb:

module Api
  module V1
    class SampleController < ApiBaseController

      def list
        render json: Model.find_by_id(params[:id])
      end

    end    
  end
end

the ApiBaseController:

module Api
  class ApiBaseController < ApplicationController
    before_filter :authenticate
    skip_before_filter :verify_authenticity_token

  private

    def authenticate
      # if params[:target] == "ios"
      #   render :json => {status: 404}
      #   return false        
      # end
    end
  end  
end

the problem is:

whenever i try to call Model i get this error:

uninitialized constant Api::V1::SampleController::Model

If i use: ::Model i get this error:

uninitialized constant Model

And yes, i do have this models on my database. If i use Model.all outside the SampleController i get the objects.

P.S.: I’m using rails 3.2.8

  • 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-06-13T20:22:16+00:00Added an answer on June 13, 2026 at 8:22 pm

    Found my problem.

    My Model was in plural and on my controller i was calling it in singular

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

Sidebar

Related Questions

I have an application that's locked down using forms authentication. There are few nightly
I have this senario. We have an application server that contains a few web
I have a few JAVA application that I monitor using JMX. I would like
I have a simple application that loads an unmanaged dll and passes a few
We use MVC controllers that access System.File.IO in our application and they work fine
My application communicates with several GSM electric controllers, that means that I have to
I want to create web application using Grails. The main layout consists of few
If I have an application with only a few event handlers registered (and the
in my application I have a few CListCtrl tables. I fill/refresh them with data
We have a winforms application calling a stored procedure every few seconds. The stored

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.