find() not returning value of dynamically renamed field

Hi,

I have a database table, containing a large number of fields, among
which a bunch of i18n fields, like DESC_EN, DESC_FR, DESC_DE, etc. I
would like to dynamically select which one of these fields I will
return, by using SQL's "AS" pointing to the same field name:
DESCRIPTION_I18N.

My Rails code looks something like this:

### MODEL ###

  def description_i18n
# The actual field is selected dynamically:
    self[:desc_fr]
  end

### CONTROLLER ###

@my_data = MyTable.find(
  :all,
  :select => "ID, CODE, DESC_FR AS DESCRIPTION_I18N",
  :conditions => conditions_list)
@my_data_i18n = @my_data.to_xml :methods => [:description_i18n]
render :xml => @my_data_i18n

Hi,

I have a database table, containing a large number of fields, among
which a bunch of i18n fields, like DESC_EN, DESC_FR, DESC_DE, etc. I
would like to dynamically select which one of these fields I will
return, by using SQL's "AS" pointing to the same field name:
DESCRIPTION_I18N.

does it not like the fact that you have 2 things that are identical
apart from the case?
Also won't this fail because the description_i18n method wants the
desc_fr field which isn't available with that name?

Fred

does it not like the fact that you have 2 things that are identical
apart from the case?

That's not the problem, because the case is irrelevant in SQL (at least
as far as Oracle is concerned); this works fine with all other fields.

Also won't this fail because the description_i18n method wants the
desc_fr field which isn't available with that name?

I see your point: I don't need to mention DESCRIPTION_I18N, because
Rails creates it in to_xml(). So removing "AS DESCRIPTION_I18N" solved
my problem.

Thanks again,

Chris.