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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:55:08+00:00 2026-06-17T09:55:08+00:00

I have a rails controller and a resque worker. Both share a couple of

  • 0

I have a rails controller and a resque worker. Both share a couple of functions. Where should I put these functions so that I can follow the DRY principle and Rails conventions?

  • 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-17T09:55:09+00:00Added an answer on June 17, 2026 at 9:55 am

    To me, this sounds like a good case for a service layer. One of my coworkers wrote up a nice summary of the concept: http://blog.carbonfive.com/2012/01/10/does-my-rails-app-need-a-service-layer/

    In Domain-Driven Design, Evans defines a service as an operation
    offered as an interface that stands alone in the model. In other
    words, a service is an action, not a thing. And instead of forcing the
    operation into an existing object, we should encapsulate it in a
    separate, stateless service.

    …

    A domain service scripts a use-case
    involving multiple domain objects. Forcing this logic into a domain
    object is awkward because these use-cases often involve rules outside
    the responsibility of any single object.

    Service layers are a common feature in many other web app MVC frameworks and something many Rails applications choose to use when fat models do not provide an appropriate encapsulation of responsibilities in their problem domain.

    Without knowing more I’m afraid I can’t offer a more specific answer. My next step would be to try to consider what this service should be named. Is it a factory that build something we have a name for? Do is fulfill a specific role we can name it after?

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

Sidebar

Related Questions

I have a Rails controller action to test. In that action, a method User.can?
I have a Rails application that unfortunately after a request to a controller, has
I have created a rails controller that returns JSON data. So, I cannot render
I have a Rails controller set up that when a user creates a new
I have a Rails 3.1 controller that renders a user's contacts, including associated email
In my Rails controller I have something like: def authenticate_user! if not current_user #
I have this command in a Rails controller open(source) { |s| content = s.read
I have a simple problem regarding a loop in a Rails controller. Here's the
I have a Rails app with the usual application_controller, and a controller (and model)
I currently have the following controller method in a Rails app: def index @entries

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.