我想將此.json.rabl視圖轉換爲.json.erb,並且由於im非常新,所以我正在尋找實現此目標的方向。什麼是最好的方式去做這件事? 將Rabl轉換爲Erb json視圖
object @perform
attributes :id => :team_id
attributes :perform_id
node(:fb_user_id) {|x| x.user.fb_user_id.to_s}
node(:first_name) {|x| x.user.first_name}
node(:last_name) {|x| x.user.last_name}
attributes :level, :jersey, :height, :weight, :positions
node(:stat_source) {|x| Stat::SOURCES.key(x.stat_source)}
if [email protected] node({}, :if => lambda{ |m| @event.present? }) do |x| { mvp_votes: Vote.player_vote_count(@event.id, x.id) } end end
if [email protected] && (@_options[:event] || @event) node :stats do |perform| Hash[*perform.source_stats.where(event_id: (@_options[:event].try(:id) || @event.id)).map{|x|[x.name, x.value]}.flatten] end end