ruby-on-rails - ActiveRecord 模型的保留名称

标签 ruby-on-rails ruby-on-rails-3 activerecord ruby-on-rails-3.2 active-record-query

我非常重视命名,因此我非常认真地为我的 ActiveRecord 模型考虑好的名称。然而,我经常想出一个名称,它与数据库或 Ruby 或 Rails 中的保留名称有一些冲突。模型或字段名称,例如 setgroup。有时问题也不会立即显现出来。是否有一个我们不能在模型名称中使用的名称列表和一个字段名称列表?

最佳答案

保留字列表

ADDITIONAL_LOAD_PATHS
ARGF
ARGV
ActionController
ActionView
ActiveRecord
ArgumentError
Array
BasicSocket
Benchmark
Bignum
Binding
CGI
CGIMethods
CROSS_COMPILING
Class
ClassInheritableAttributes
Comparable
ConditionVariable
Config
Continuation
DRb
DRbIdConv
DRbObject
DRbUndumped
Data
Date
DateTime
Delegater
Delegator
Digest
Dir
ENV
EOFError
ERB
Enumerable
Errno
Exception
FALSE
FalseClass
Fcntl
File
FileList
FileTask
FileTest
FileUtils
Fixnum
Float
FloatDomainError
GC
Gem
GetoptLong
Hash
IO
IOError
IPSocket
IPsocket
IndexError
Inflector
Integer
Interrupt
Kernel
LN_SUPPORTED
LoadError
LocalJumpError
Logger
Marshal
MatchData
MatchingData
Math
Method
Module
Mutex
Mysql
MysqlError
MysqlField
MysqlRes
NIL
NameError
NilClass
NoMemoryError
NoMethodError
NoWrite
NotImplementedError
Numeric
OPT_TABLE
Object
ObjectSpace
Observable
Observer
PGError
PGconn
PGlarge
PGresult
PLATFORM
PStore
ParseDate
Precision
Proc
Process
Queue
RAKEVERSION
RELEASE_DATE
RUBY
RUBY_PLATFORM
RUBY_RELEASE_DATE
RUBY_VERSION
Rack
Rake
RakeApp
RakeFileUtils
Range
RangeError
Rational
Regexp
RegexpError
Request
RuntimeError
STDERR
STDIN
STDOUT
ScanError
ScriptError
SecurityError
Signal
SignalException
SimpleDelegater
SimpleDelegator
Singleton
SizedQueue
Socket
SocketError
StandardError
String
StringScanner
Struct
Symbol
SyntaxError
SystemCallError
SystemExit
SystemStackError
TCPServer
TCPSocket
TCPserver
TCPsocket
TOPLEVEL_BINDING
TRUE
Task
Text
Thread
ThreadError
ThreadGroup
Time
Transaction
TrueClass
TypeError
UDPSocket
UDPsocket
UNIXServer
UNIXSocket
UNIXserver
UNIXsocket
UnboundMethod
Url
VERSION
Verbose
YAML
ZeroDivisionError
@base_path
accept
Acces
Axi
action
attributes
application2
callback
category
connection
database
dispatcher
display1
drive
errors
format
host
key
layout
load
link
new
notify
open
public
quote
render
request
records
responses
save
scope
send
session
system
template
test
timeout
to_s
type
URI
visits
Observer

数据库字段名称

created_at
created_on
updated_at
updated_on
deleted_at
(paranoia
gem)
lock_version
type
id
#{table_name}_count
position
parent_id
lft
rgt
quote_value

Ruby 保留字

alias
and
BEGIN
begin
break
case
class
def
defined?
do
else
elsif
END
end
ensure
false
for
if
module
next
nil
not
or
redo
rescue
retry
return
self
super
then
true
undef
unless
until
when
while
yield
_ FILE _
_ LINE _

关于ruby-on-rails - ActiveRecord 模型的保留名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13750009/

相关文章:

ruby-on-rails - 销毁用户后清除 session

ruby-on-rails - 带有 mongoid、devise、database_cleaner 的 rspec:ActiveRecord::ConnectionNotEstablished 错误

ruby-on-rails - 更新: Free tools for checking security vulnerabilities for rails app

ruby-on-rails-3 - 使用回形针和延迟作业将图像后台上传到 S3

ruby-on-rails - 如何在 Rails 3.2.20 中强制 Cache-Control 不存储

activerecord - 你知道如何在 CaSTLe ActiveRecord 中实现事务吗?

ruby-on-rails - rails : Find records with a certain combination of associated records

java - 在 Netbeans 中打开的窗口之间切换

ruby-on-rails-3 - 如何从 Rails 3 中的模型获取实际的 HTTP 请求?

ruby-on-rails - Rails,find_by().present 存在吗?比 where().exists 性能更高?