没有数据库的 Rails 模型 [英] Rails model without database

查看:39
本文介绍了没有数据库的 Rails 模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个带有 ActiveRecord 验证的 Rails(2.1 和 2.2)模型,但没有数据库表.使用最广泛的方法是什么?我发现了一些声称提供此功能的插件,但其中许多似乎并未得到广泛使用或维护.社区建议我做什么?现在我倾向于根据 这篇博文.

I want to create a Rails (2.1 and 2.2) model with ActiveRecord validations, but without a database table. What is the most widely used approach? I've found some plugins that claim to offer this functionality, but many of them don't appear to be widely used or maintained. What does the community recommend I do? Right now I am leaning toward coming up with my own solution based on this blog post.

推荐答案

我认为您链接的博客文章是最好的方法.我只建议将被剔除的方法移到模块中,以免污染您的代码.

I think the blog post you are linking is the best way to go. I would only suggest moving the stubbed out methods into a module not to pollute your code.

这篇关于没有数据库的 Rails 模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆