`
fei1985
  • 浏览: 34388 次
  • 性别: Icon_minigender_1
  • 来自: 济南
最近访客 更多访客>>
社区版块
存档分类
最新评论

由于保留字引起 Can't mass-assign these protected attributes 的错误

阅读更多

做一个例子的时候  数据库中使用了一列为type,结果报出了错误, 我比较奇怪我在model中并没有进行相关的设置, 后来想想可能是与rails的保留字冲实了 ,google的一下 结果的确是这样。因为是保留字,系统自动保护不让外部赋值。

 

下面是网站搜索到的相关保留字。可能还不是最全的

 

这是rails官方网上给的相关说明:http://wiki.rubyonrails.org/rails/pages/ReservedWords, 

 

 

Ruby Reserved Words

  1. alias                   and                     BEGIN
  2. begin                   break                   case
  3. class                   def                     defined
  4. do                      else                    elsif
  5. END                     end                     ensure
  6. false                   for                     if
  7. in                      module                  next
  8. nil                     not                     or
  9. redo                    rescue                  retry
  10. return                  self                    super
  11. then                    true                    undef
  12. unless                  until                   when
  13. while                   yield

Ruby on Rails Reserved Words

  1. ADDITIONAL_LOAD_PATHS   ARGF                            ARGV
  2. ActionController        ActionView                      ActiveRecord
  3. ArgumentError           Array                           BasicSocket
  4. Benchmark               Bignum                          Binding
  5. CGI                     CGIMethods                      CROSS_COMPILING
  6. Class                   ClassInheritableAttributes      Comparable
  7. ConditionVariable       Config                          Continuation
  8. DRb                     DRbIdConv                       DRbObject
  9. DRbUndumped             Data                            Date
  10. DateTime                Delegater                       Delegator
  11. Digest                  Dir                             ENV
  12. EOFError                ERB                             Enumerable
  13. Errno                   Exception                       FALSE
  14. FalseClass              Fcntl                           File
  15. FileList                FileTask                        FileTest
  16. FileUtils               Fixnum                          Float
  17. FloatDomainError        GC                              Gem
  18. GetoptLong              Hash                            IO
  19. IOError                 IPSocket                        IPsocket
  20. IndexError              Inflector                       Integer
  21. Interrupt               Kernel                          LN_SUPPORTED
  22. LoadError               LocalJumError                   Logger
  23. Marshal                 MatchData                       MatchingData
  24. Math                    Method                          Module
  25. Mutex                   Mysql                           MysqlError
  26. MysqlField              MysqlRes                        NIL
  27. NameError               NilClass                        NoMemoryError
  28. NoMethodError           NoWrite                         NotImplementedError
  29. Numeric                 OPT_TABLE                       Object
  30. ObjectSpace             Observable                      Observer
  31. PGError                 PGconn                          PGlarge
  32. PGresult                PLATFORM                        PStore
  33. ParseDate               Precision                       Proc
  34. Process                 Queue                           RAKEVERSION
  35. RELEASE_DATE            RUBY                            RUBY_PLATFORM
  36. RUBY_RELEASE_DATE       RUBY_VERSION                    Rake
  37. RakeApp                 RakeFileUtils                   Range
  38. RangeError              Rational                        Regexp
  39. RegexpError             Request                         RuntimeError
  40. STDERR                  STDIN                           STDOUT
  41. ScanError               ScriptError                     SecurityError
  42. Signal                  SignalExceptio                  SimpleDelegater
  43. SimpleDelegator         Singleton                       SizedQueue
  44. Socket                  SocketError                     StandardError
  45. String                  StringScanner                   Struct
  46. Symbol                  SyntaxError                     SystemCallError
  47. SystemExit              SystemStackError                TCPServer
  48. TCPSocket               TCPserver                       TCPsocket
  49. TOPLEVEL_BINDING        TRUE                            Task
  50. Text                    Thread                          ThreadError
  51. ThreadGroup             Time                            Transaction
  52. TrueClass               TypeError                       UDPSocket
  53. UDPsocket               UNIXServer                      UNIXSocket
  54. UNIXserver              UNIXsocket                      UnboundMethod
  55. Url                     VERSION                         Verbose
  56. YAML                    ZeroDivisionError

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics