I’ve written a code with acts_as_api for a dates_model. The code is as following. It never fetches the dates. Am I doing anything wrong. The code is as follows
acts_as_api
api_accessible :bill_corrections do |inv|
inv.add :common_date, :as => :recieved_date, :if => lambda{|u|u.date_type_code=="RECVD"}
inv.add :common_date, :as => :actual_date, :if => lambda{|u|u.date_type_code=="ARRIV"}
end
I’ve my schema for datefield
create_table "item_dates", :force => true do |t|
t.integer "item_date_id", :limit => 10
t.string "date_type_code"
t.datetime "common_date"
t.datetime "created_at"
t.datetime "updated_at"
end
I’m the creator of acts_as_api. I tried your use case with a minimal Rails app and it worked for me. Here is an example response in xml:
The api template in the model looks like this:
And this is a dump of User.all:
Did you check that you use the controller helpers correctly?
I hope this helps. 🙂
Further debugging could include:
* What happens if you remove the :if options?
* What does ‘puts u.date_type_code’ say if you put it in the :if options blocks?