views:

42

answers:

1

Hi,

If I have an object say

@user

and I want to render only certain fields in it say first_name and last_name(I'm using AMF)

render :amf => @user

For instance I have a property for @user which is 'dob' (date of birth) I would like to use it inside the controller business logic but I don't want to send it to the client (in this case Flex) I can defenitaly do something like this before rendering:

@user.dob = nil

But I thought there must be a better way of doing this.

how do I do that?

I know I can use :select when doing the 'find' but I need to use the other field at the server side but don't want to send them with AMF to the client side and I don't want to do a second 'find'

Thanks,

Tam

+1  A: 

This article gives the details for the approach.

You have configure the config/rubyamf_config.rb file as follows:

require 'app/configuration'
module RubyAMF
  module Configuration
    ClassMappings.ignore_fields   = ['created_at','updated_at']
    ClassMappings.translate_case  = true
    ClassMappings.assume_types    = false
    ParameterMappings.scaffolding = false

    ClassMappings.register(
      :actionscript  => 'User',
      :ruby          => 'User',
      :type          => 'active_record',
      :associations  => ["employees"],
      :ignore_fields => ["dob"]
      :attributes    => ["id", "name", "location", "created_at", "updated_at"]
    )

    ClassMappings.force_active_record_ids = true
    ClassMappings.use_ruby_date_time = false
    ClassMappings.use_array_collection = true
    ClassMappings.check_for_associations = true
    ParameterMappings.always_add_to_params = true
   end
end
KandadaBoggu