When should you use RESTful controllers in your Rails application, and when not?

I am looking for recommendations on when to know when a RESTful approach to a model and its associations are correct and when not. This may be the nature of my current application, but I find that simple models without any associations work well with REST, but complex models with many has_many associations really complicate the presentation and configuration needed in the controller. form_for calls begin to become especially complex.

Or perhaps this is my understanding of neophytes. I've been doing Rails for over three years now, but REST and form helpers together seem mystified to me.

+5
source share
4

. , . , . . , , . , .

class Position
  has_many :candidate_positions
  has_many :candidates, :through => :candidate_positions
end

class Candidate
  has_many :candidate_positions
  has_many :positions, :through => :candidate_positions
  has_many :past_employments
  accepts_nested_attributes_for :past_employments
  accepts_nested_attributes_for :candidate_positions
end

class PastEmployment
  belongs_to :candidate
end

class CandidatePosition
  belongs_to :candidate
  belongs_to :position
end

map.resources :positions
map.resources :candidates

, . , HomeController, , , , . , ! , , <% form_for @candidate %>. <%= render @positions %>, , Rails , views/positions/_position.html.erb .

, , . , , - . , Rails , . URL-, , .

+5

Railscasts, REST:

+1

RoR, REST.

REST ROI URL HTTP-, GET, POST, PUT DELETE . CRUD . URL- , URL-.

, , , , , , , .., REST.

0

: , . : REST - .

: , State State Transfer .

REST . , , , webapp, , .

i.e., , , , . - , webapps, , , . GET POST , , .

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

, Rails. , , .

, ? , ? ? - REST?

0
source

All Articles