Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

'#' character in column name causes ActiveModel error

#5818

I have an Oracle table which has the following column (legal in Oracle):

CASE# VARCHAR2(20)

Note the '#' character. I have this table mapped to a model class via ActiveRecord. This column name causes the following error whenever you try to use this model:

Failures:
1) Case should be valid with valid attributes

 Failure/Error: @case.save!
 /Users/bploetz/.rvm/gems/ruby-1.9.2-p0@sw-model/gems/activemodel-3.0.0/lib/active_model/attribute_methods.rb:273: syntax error, unexpected keyword_undef, expecting ')'
                     undef :case#?
                          ^
 /Users/bploetz/.rvm/gems/ruby-1.9.2-p0@sw-model/gems/activemodel-3.0.0/lib/active_model/attribute_methods.rb:274: syntax error, unexpected keyword_end, expecting $end

This comes from the following in active_model/attribute_methods.rb:

if method_defined?(:#{method_name})
undef :#{method_name} end

These evaluate to :case#, which is not a valid symbol.

Reported by Brian Ploetz · October 15th, 2010 @ 10:33 PM

State: resolved
Milestone: 3.0.2
Assigned to: nobody
Importance: Low

Activity

  1. Ryan Bigg
    Ryan Bigg
    • Tag cleared.
    • Importance changed from to Low

    Automatic cleanup of spam.

    October 19th, 2010 @ 08:33 AM

  2. Robert Pankowecki
    Robert Pankowecki
    • Tag set to activemodel, columns

    I will work on it.

    October 24th, 2010 @ 09:47 AM

  3. Aditya Sanghi
    Aditya Sanghi
    • Milestone set to 3.0.2

    Please provide a failing test and a patch as per the Contributor's guide.

    October 24th, 2010 @ 02:33 PM

  4. Repository
    Repository
    • State changed from new to resolved

    (from [88688cdd8e467d4bdebfa3f08e47cd5e7c5ead2c]) Fix when database column name has some symbolic characters. [#5818 state:resolved] https://github.com/rails/rails/commit/88688cdd8e467d4bdebfa3f08e47c...

    November 14th, 2010 @ 09:24 AM

  5. Repository