Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rails: datetimes fields do not fetch the values
- 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
- 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
- <users type="array">
- <user>
- <first-name>Me</first-name>
- <recieved-date type="datetime">2011-10-07T08:20:02Z</recieved-date>
- </user>
- <user>
- <first-name>Me2</first-name>
- <actual-date type="datetime">2011-10-07T08:20:52Z</actual-date>
- </user>
- </users>
- api_accessible :test_dates do |t|
- t.add :first_name
- t.add :common_date, :as => :recieved_date, :if => lambda{|u|u.date_type_code=="RECVD"}
- t.add :common_date, :as => :actual_date, :if => lambda{|u|u.date_type_code=="ARRIV"}
- end
- [
- [0] #<User:0x0000010b859308> {
- :id => 1,
- :first_name => "Me",
- :last_name => "Too",
- :age => nil,
- :active => nil,
- :created_at => Fri, 07 Oct 2011 08:20:19 UTC +00:00,
- :updated_at => Fri, 07 Oct 2011 08:20:19 UTC +00:00,
- :date_type_code => "RECVD",
- :common_date => Fri, 07 Oct 2011 08:20:02 UTC +00:00
- },
- [1] #<User:0x0000010b858688> {
- :id => 2,
- :first_name => "Me2",
- :last_name => "Too2",
- :age => nil,
- :active => nil,
- :created_at => Fri, 07 Oct 2011 08:20:45 UTC +00:00,
- :updated_at => Fri, 07 Oct 2011 08:20:53 UTC +00:00,
- :date_type_code => "ARRIV",
- :common_date => Fri, 07 Oct 2011 08:20:52 UTC +00:00
- }
- ]
- def index
- @users = User.all
- respond_to do |format|
- format.html # index.html.erb
- format.xml { render_for_api :test_dates, :xml => @users, :root => :users }
- format.json { render_for_api :test_dates, :json => @users, :root => :users }
- end
- end
Add Comment
Please, Sign In to add comment