lib/restful_controller/actions/create.rb in restful-controller-0.0.2 vs lib/restful_controller/actions/create.rb in restful-controller-0.0.3
- old
+ new
@@ -1,9 +1,15 @@
module RestfulController
module Actions
module Create
def create
- self.class.model_class.create(model_params)
+ model = self.class.model_class.build(model_params)
+ instance_variable_set("@#{self.class.model_name}", model)
+ if model.save
+ redirect_to model, notice: "#{model.name} was successfully created."
+ else
+ render action: 'new'
+ end
end
end
end
end
\ No newline at end of file