From 1f9d234a6b567e68d97e71da6f19bd126e7f7058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 17 Oct 2009 15:56:44 -0300 Subject: By default use ActiveModel API in controller generators, unless otherwise specified [#3123 status:resolved] --- railties/lib/rails/generators/active_model.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'railties/lib/rails/generators/active_model.rb') diff --git a/railties/lib/rails/generators/active_model.rb b/railties/lib/rails/generators/active_model.rb index 1a849a0e02..fe6321af30 100644 --- a/railties/lib/rails/generators/active_model.rb +++ b/railties/lib/rails/generators/active_model.rb @@ -32,7 +32,7 @@ module Rails # GET index def self.all(klass) - raise NotImplementedError + "#{klass}.all" end # GET show @@ -40,34 +40,38 @@ module Rails # PUT update # DELETE destroy def self.find(klass, params=nil) - raise NotImplementedError + "#{klass}.find(#{params})" end # GET new # POST create def self.build(klass, params=nil) - raise NotImplementedError + if params + "#{klass}.new(#{params})" + else + "#{klass}.new" + end end # POST create def save - raise NotImplementedError + "#{name}.save" end # PUT update def update_attributes(params=nil) - raise NotImplementedError + "#{name}.update_attributes(#{params})" end # POST create # PUT update def errors - raise NotImplementedError + "#{name}.errors" end # DELETE destroy def destroy - raise NotImplementedError + "#{name}.destroy" end end end -- cgit v1.2.3