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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:54:30+00:00 2026-05-17T19:54:30+00:00

I’m working on a gaming app (mobile front ends, Rails backend) and trying to

  • 0

I’m working on a gaming app (mobile front ends, Rails backend) and trying to decide if I should go strictly RESTful. It appears that I’ll be creating a lot more controllers if I do so. For example, there are several game actions I need to implement like attack, defend, etc. If I go strictly RESTful, I’ll need to create a controller for each game action with only one REST action (update). If I go non-RESTul and creates say a generic battle controller, I can then create methods/actions for attack, defend, etc. Seems like more hassle to go strictly RESTful.

Any insights will be much appreciated.

  • 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-17T19:54:30+00:00Added an answer on May 17, 2026 at 7:54 pm

    Attack, defend, etc are all of the same kind of resource: Action.

    E.g.:

    PUT actions/attack # to attack
    PUT actions/defend # to defend
    GET actions        # to get the list of all available actions
    

    To implement this as REST, I’d go something like this:

    class PlayerActionsController ...
       def index
          @actions = PlayerAction.all
          respond_with @actions
       end
    
       def update
          @action   = PlayerAction.find(params[:id])        
          respond_with @action.perform(params)
       end
    end
    
    
    class GenericAction
       attr_readable :name
    
       def initialize(name)
         @name = name
       end
    
       def perform(arguments)
         self.send(name, arguments) if self.class.find(name)
       end
    
       ACTIONS = []
       ACTIONS_BY_NAME = {}
       class << self
         def add_action(*names)
            names.each do |name|
              action = Action.new(name)
              ACTIONS_BY_NAME[name] = action
              ACTIONS << action
            end
         end
    
         def index
           ACTIONS.dup
         end      
    
         def find(name)
           ACTIONS_BY_NAME[name]
         end
       end
    def
    
    class PlayerAction < GenericAction
       add_action :attack, :defend
    
       def attack(params)
          player, target = Player.find(params[:player_id]), Player.find(params[:target_id])
          ...
       end
    
    
       def defend(params)
          ...
       end
    end
    

    This is just to give a rough idea of how it could be done well.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want use html5's new tag to play a wav file (currently only supported
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.