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 7747871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:38:16+00:00 2026-06-01T10:38:16+00:00

In the Rails application I’m currently developing I have many request models. We are

  • 0

In the Rails application I’m currently developing I have many “request” models. We are using a lot of web services and we have a lot of different requests to those services, each of them with their own logic (mostly validations). So they are all grouped in a module as a namespace:

module Request
end

So now every request is something like:

class Request::SendSomeData
end

So far, so good… The thing is that we are going to have a lot of such requests which will share some common logic. It is easy to include the module

class Request::SendSomeData
  include Request
end

… (so it will act both as a namespace and a mixin), but I was wondering if there is a way to make it without the include (as it is going to be some kind of code repetition).

Is there a way for Ruby to put some instance methods to all the classes in a module’s namespace without explicitly including the module?

In other words can I have something like:

module Request
  def someMethod
  end
end

and

class Request::SendSomeData
end

and be able to use

Request::SendSomeData.new.someMethod

at the same time?

  • 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-01T10:38:18+00:00Added an answer on June 1, 2026 at 10:38 am

    What you are asking can’t be done without some evil hackery.

    You either have too many classes, or are focusing on an issue that is too unimportant. It’s only one line of code per class.

    An alternative is to create a base model class, as I have previously described in another question, but this requires the derived classes to each call set_table_name, so it won’t save you any typing.

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

Sidebar

Related Questions

Background Currently, I am working on a Rails application. I have different products that
I am currently developing a Rails application using a database that was designed before
I currently have a Ruby (Rails) application that needs to make a lot of
I'm currently developing a Rails application to accept recurring billing using Chargify. I've installed
I am currently deploying a Rails application using Capistrano. Cap deploy:update_code usually works just
I have a rails 3.0.9 application that I am currently trying to deploy. The
We're working on some Ruby on Rails web application which is currently in English
G'day guys, currently have almost finished writing a rails application that allows a CSV
All, I am using the Flot graphing library in my rails application. I currently
I am co-developing a simple web app in Rails 3.0.9 and I have realized

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.