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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:44:52+00:00 2026-05-20T04:44:52+00:00

I have an existing site that has a bunch of different models and controllers.

  • 0

I have an existing site that has a bunch of different models and controllers. I am currently integrating Twilio’s services into this site. Twilio allows you to supply a url that will be called when a user interacts with your phone number using their phone. Unfortunately, there is only one url that you can provide to Twilio and then all the parsing is done on your end.

So, now I have a twilio controller which parses the user’s data and decides what they are trying to do.

Everything the user may be trying to do via their phone can be done on the website already, but now they have the option to use their phone when on the go. If they text my number “create group foo” then the site will try to create the group accordingly. My issue is that I already have a groups controller that knows how to create groups and has the appropriate before_filters to make sure that the user has permission to do so, amongst other things.

Is there a way for the twilio controller to parse the request and then “forward” it over to the proper controller in some way? I’d rather not have the twilio controller duplicate all of the code and filters that are in every other controller and some of that stuff doesn’t feel right to be shoved into the models.

I’m somewhat new to rails in general, so I’m open to any suggestion. I’m hoping there’s some design pattern out there that fits my use case and I’m willing to refactor my whole project for the correct solution.

  • 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-20T04:44:53+00:00Added an answer on May 20, 2026 at 4:44 am

    I think there are a couple of things you can do. If you don’t have to respond in a certain format, then you can simply redirect the request with the appropriately formatted parameters. For example:

    class TwilioController
      def create
        if params[:twilio_action] == 'create group'
          redirect_to create_group_path(:id => params[:group_id], :number => params[:number])
        end
      end
    end
    

    There’s a good chance that you’ll have problems with authentication though, because the twilio api will not be sending and receiving cookies for you, so you will not have an authenticated user. If this is the case it will be best to put all your shared code in the model and handle cookie authentication with your GroupsController and phone number authentication with your TwilioController. For example:

    class TwilioController
      def create
        if params[:twilio_action] == 'create group'
          if can_create_group?(params[:phone_number])
            Group.create(:id => params[:group_id])
          end
        end
      end
    end
    

    It’s always best to put your business logic in your model, but if you do actually have a function you want to share within two controllers you can always create a module to do that as well:

    module GroupControllerActions
      def create_group user
        Group.create(params[:group].merge({:user => user}))
      end
    end
    
    class TwilioController
      include GroupControllerActions
    
      def create
        if params[:twilio_action] == 'create group'
          create_group(User.find_by_number(params[:phone_number]))
        end
      end
    end
    
    class GroupsController
      def create
        create_group(current_user)
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an existing application that imports data from a web site api into
I have an existing Django project that has several models using concrete inheritance of
I have an existing site that requires a background image on the home page.
I have a web server that has existing pages in it that are created
I have an existing asp.net mvc website that uses basic forms authentication. The site
I have an existing site (where nearly every line has been coded by hand)
I have an ASP.NET 3.5 e-commerce site that has an admin section. I want
I am updating an existing ASP .NET site. This site has a custom grid
We have a very large existing site that we're going to do a completely
I have an existing site (social in nature) and it already has a mobile

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.