ActiveModel - View - Controller in Rails instead of ActiveRecord?

后端 未结 2 1533
傲寒
傲寒 2021-02-05 13:11

I\'m trying to use ActiveModel instead of ActiveRecord for my models because I do not want my models to have anything to do with the database.

Below is my model:

<
2条回答
  •  逝去的感伤
    2021-02-05 14:09

    Looks like you should have instead investigated the (not very well documented) ActiveModel::Conversions class

    https://github.com/rails/rails/blob/3-1-stable/activemodel/lib/active_model/conversion.rb

      include ActiveModel::Conversion
    
      def persisted?
        false
      end
    

    would have done the trick, same applies to Rails 4.2

提交回复
热议问题