How to RESTful -ize a complex controller

I have a controller with actions:

class GameController < ApplicationController
before_filter :set_titles

def prestart
end

def wait
end

def play (game)
end


def button
end

def finish
end


def set_titles
end

set_titles will get the page title (and other common properties for all actions). All other actions check something and pretend.

Like RESTful -ize. I can only think of creating a controller Wait_player controller play_game, etc., All of them will only have a show action. But it looks awkward and harder to follow that all of these related actions are in one controller.

+3
source share
3 answers

-, , RESTful . , REST, , . , , .

, REST . , , , , . , RESTful, , "prestart", new, "" create. "" destroy. "" "". RESTful . , - RESTful "wait".

. , , , , . , RESTful Rails .

" RESTful -ize . Wait_player play_game .."

, . Intead, , . , WaitPlayer Player show, new, create .. ( RESTful), wait.

+5

, . REST

pre_start , , , , , - ( )

PS: set_titles private

+2

, . REST - , , . ?

, ..

The RESTful API requires a different way to solve problems.

This link talks about RESTful WCF services, but RESTful thinking stuff should also apply in your domain.

+1
source

Source: https://habr.com/ru/post/1711505/


All Articles