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

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

问题描述

我想创建一个Rails(2.1和2.2)模型ActiveRecord的验证,但没有一个数据库表。什么是最广泛使用的方法?我发现一些插件,声称能提供此功能,但其中许多人似乎并没有得到广泛的应用和维护。什么是社区推荐我做什么?现在我倾向于根据<一个未来与自己的解决方案href="http://www.$p$pstonlee.com/2007/12/29/rails-20-validations-without-extending-activerecordbase/">this博客文章。

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.

推荐答案

我觉得你要链接的博客文章是最好的一段路要走。我只会建议移动掐灭方法到一个模块中不污染你的code。

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天全站免登陆