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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:50:05+00:00 2026-05-22T22:50:05+00:00

Basically, I’m in the process of writing a website that interfaces with many popular

  • 0

Basically, I’m in the process of writing a website that interfaces with many popular websites (Facebook, Twitter, Youtube etc). My principal objective will be the same, however the way I accomplish my objective will be different for every site I support, because their layout is different and because I’ll have to script my requests based off the workings of their website.

The user chooses which particular website they want to use the service I offer for (i.e. do they want to use it for facebook, or for twitter, etc). And they can only choose 1 of these websites per request of my service.

I’m wondering what a good design principal/practice is when it comes to Rails modularization (this is my first Rails project, I’ve had lots of exposure to other languages though). Basically, the way I see it is, a user will submit their request to my controller, which will check what site they chose. My controller will then “load” a particular module (i.e. if they chose facebook, it would load the facebook module), which will contain all of the code for dealing with Facebook requests. It will then call this code in whatever way necessary, and serve results to the user.

So basically, my question is really coming down to best practice and design principles in regards to Rails. How do you think a good way to separate my code is in this instance? Should I have a class for every site I support (facebook, twitter, etc)? This is the only real option I can think of (because I’m not very familiar with Rails), however I’m sure there would be a better option, so I can limit the amount of code redundancy, as the goal of each class will be the same, it’ll just be a different technique to obtaining the goal (i.e. the method names will be the same for every class, etc).

Thanks!

  • 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-22T22:50:05+00:00Added an answer on May 22, 2026 at 10:50 pm

    Looks like the strategy pattern to me. You could do it like this (not sure where to put it in Rails).

    require "delegate"
    
    class Youtube
      def open_connection
        #code to open connection with youtube
      end
    
      def do_stuff    
        puts "doing stuff on Youtube" 
      end
    
      def close_connection
        #code to close connection
      end
    end
    
    class Facebook
      #define the same methods here
    end
    
    
    class Service < SimpleDelegator
      def hello
        puts "Hello, I stole most of my methods from #{__getobj__}"
      end
    end
    
    
    s = Service.new(Youtube.new)
    s.hello     #=> Hello, I stole most of my methods from #<Youtube:0xb7724b1c>
    s.do_stuff  #=> doing stuff on Youtube
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I’ve heard that certain conditions will cause .NET to blow past the finally
Basically I'm trying to accomplish the same thing that mailto:bgates@microsoft.com does in Internet Explorer
Basically I need to open a login window in a popup, so that it
Basically I want to achieve such functionality that 5-10 functions are executed in a
basically I'm trying to pass a variable that is defined in a JSON array
Basically what I need is an script that, when provided with a time and
Basically what I want to do it this: a pdb file contains a location
Basically, something better than this: <input type=file name=myfile size=50> First of all, the browse
Basically I have some code to check a specific directory to see if an
Basically I'm going to go a bit broad here and ask a few questions

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.