I have a database that I want to create a rails frontend for,
and am attempting with rails 3.0.0beta. One of the tables has a
column named 2_3. rails tries to create method accessors, and ruby
wants them to be starting with [a-z_].
irb(main):001:0> Task.find(1)
=> #<Task id: 1, user: "cwevans", tid: 11464, comment: "", created_at: "2010-02-15 07:57:02", updated_at: "2010-02-15 07:57:02">
irb(main):002:0> Task.find(1).em7_ticket
=> #<Em7Ticket tid: 11464, Xid: 25135, Xtype: 0, Xname: "", aid: 0, roa_id: 25006, roa_lid: 0, class: 15, descr: "Duplicate VIP recap", severity: 4, status: 0, source: 45, date_create: "2010-01-26 15:26:01", user_create: "system", date_update: "2010-02-09 16:44:01", user_update: "system", assign: 34, assigned_to: "cwevans", resolution: 0, cause: 0, escalation: 2, hours_billed: 0.0, user_close: "", date_close: nil, close_age: "", auto_close: 0, master_tid: 0, 2_1: "- No Project -">
irb(main):003:0> Task.find(1).em7_ticket.task
SyntaxError: compile error
/usr/local/lib/ruby/gems/1.8/gems/activemodel-3.0.0.beta/lib/active_model/attribute_methods.rb:258: syntax error, unexpected tINTEGER
def 2_1?(*args)
^
/usr/local/lib/ruby/gems/1.8/gems/activemodel-3.0.0.beta/lib/active_model/attribute_methods.rb:258: syntax error, unexpected ')', expecting '='
/usr/local/lib/ruby/gems/1.8/gems/activemodel-3.0.0.beta/lib/active_model/attribute_methods.rb:260: syntax error, unexpected kEND, expecting ')'
from /usr/local/lib/ruby/gems/1.8/gems/activemodel-3.0.0.beta/lib/active_model/attribute_methods.rb:260:in `define_attribute_methods'
from /usr/local/lib/ruby/gems/1.8/gems/activemodel-3.0.0.beta/lib/active_model/attribute_methods.rb:250:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/activemodel-3.0.0.beta/lib/active_model/attribute_methods.rb:250:in `define_attribute_methods'
from /usr/local/lib/ruby/gems/1.8/gems/activemodel-3.0.0.beta/lib/active_model/attribute_methods.rb:249:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/activemodel-3.0.0.beta/lib/active_model/attribute_methods.rb:249:in `define_attribute_methods'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta/lib/active_record/attribute_methods.rb:12:in `define_attribute_methods'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta/lib/active_record/attribute_methods.rb:41:in `respond_to?'
from /usr/local/lib/ruby/g
To test a similar case, I used rails 2.3.5
rails generate scaffold task 2_3:string
./script/generate scaffold task 2_3:string
[root@hold-dev-app01 attribute_number]# rake --trace db:migrate
(in /root/attribute_number)
Invoke db:migrate (first_time)
Invoke environment (first_time)
Execute environment
Execute db:migrate
rake aborted!
./db/migrate//20100217201534_create_tasks.rb:4: syntax error, unexpected tINTEGER, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in load_without_new_constant_marking'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:inload'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in new_constants_in'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:inload'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:373:in load_migration'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:369:inmigration'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:365:in migrate'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:486
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:560:incall'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:560:in ddl_transaction'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:136:intransaction'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:182:in transaction'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:560:inddl_transaction'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:485:in migrate'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:472:ineach'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:472:in migrate'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:400:inup'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:383:in migrate'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/databases.rake:116
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:incall'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:ineach'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:ininvoke_with_call_chain'
/usr/local/lib/ruby/1.8/monitor.rb:242:in synchronize'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_chain'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in invoke'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:ininvoke_task'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:ineach'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:inrun'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:inrun'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/local/bin/rake:19:in load'
/usr/local/bin/rake:19</code>
</pre>