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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:09:34+00:00 2026-05-19T01:09:34+00:00

I need some help figuring out the best way to proceed with creating a

  • 0

I need some help figuring out the best way to proceed with creating a Rails 3 engine(or plugin, and/or gem).

Apologies for the length of this question…here’s part 1:

My company uses an email service provider to send all of our outbound customer emails. They have created a SOAP web service and I have incorporated it into a sample Rails 3 app. The goal of creating an app first was so that I could then take that code and turn it into a gem.

Here’s some of the background: The SOAP service has 23 actions in all and, in creating my sample app, I grouped similar actions together. Some of these actions involve uploading/downloading mailing lists and HTML content via the SOAP WS and, as a result, there is a MySQL database with a few tables to store HTML content and lists as a sort of “staging area”.

All in all, I have 5 models to contain the SOAP actions (they do not inherit from ActiveRecord::Base) and 3 models that interact with the MySQL database.

I also have a corresponding controller for each model and a view for each SOAP action that I used to help me test the actions as I implemented them.

So…I’m not sure where to go from here. My code needs a lot of DRY-ing up. For example, the WS requires that the user authentication info be sent in the envelope body of each request. So, that means each method in the model has the same auth info hard coded into it which is extremely repetitive; obviously I’d like for that to be cleaner. I also look back now through the code and see that the requests themselves are repetitive and could probably be consolidated.

All of that I think I can figure out on my own, but here is something that seems obvious but I can’t figure out. How can I create methods that can be used in all of my models (thinking specifically of the user auth part of the equation).

Here’s part 2:

My intention from the beginning has been to extract my code and package it into a gem incase any of my ESP’s other clients could use it (plus I’ll be using it in several different apps). However, I’d like for it to be very configurable. There should be a default minimal configuration (i.e. just models that wrap the SOAP actions) created just by adding the gem to a Gemfile. However, I’d also like for there to be some tools available (like generators or Rake tasks) to get a user started. What I have in mind is options to create migration files, models, controllers, or views (or the whole nine yards if they want).

So, here’s where I’m stuck on knowing whether I should pursue the plugin or engine route. I read Jordan West’s series on creating an engine and I really like the thought of that, but I’m not sure if that is the right route for me.

So if you’ve read this far and I haven’t confused the hell out of you, I could use some guidance 🙂

Thanks

  • 1 1 Answer
  • 2 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-19T01:09:34+00:00Added an answer on May 19, 2026 at 1:09 am

    Let’s answer your question in parts.

    Part One

    Ruby’s flexibility means you can share code across all of your models extremely easily. Are they extending any sort of class? If they are, simply add the methods to the parent object like so:

    class SOAPModel
      def request(action, params)
        # Request code goes in here
      end
    end
    

    Then it’s simply a case of calling request in your respective models. Alternatively, you could access this method statically with SOAPModel.request. It’s really up to you. Otherwise, if (for some bizarre reason) you can’t touch a parent object, you could define the methods dynamically:

    [User, Post, Message, Comment, File].each do |model|
      model.send :define_method, :request, proc { |action, params|
        # Request code goes in here
      }
    end
    

    It’s Ruby, so there are tons of ways of doing it.

    Part Two

    Gems are more than flexible to handle your problem; both Rails and Rake are pretty smart and will look inside your gem (as long as it’s in your environment file and Gemfile). Create a generators directory and a /name/name_generator.rb where name is the name of your generator. The just run rails g name and you’re there. Same goes for Rake (tasks).

    I hope that helps!

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

Sidebar

Related Questions

I'm having some trouble figuring out the best/Djangoic way to do this. I'm creating
I need some help on figuring out a way to store my data that
I need some help figuring out how I should do this. I would like
Hey all, i am in need of some help with figuring out how to
I need some help figuring out a query I have 3 tables sources id,
I need some help figuring out how to do something. I got this gallery
I'm a n00b and I need some help figuring out this issue, I would
I need some help figuring out how to write this .htaccess . My file
I need some help figuring out what I'm doing wrong here. I am trying
need some help figuring this out. My function: function cleanDatabase() { $allowedTime = $this->time

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.