Skip to content

Instantly share code, notes, and snippets.

@mk0x9
Created March 2, 2012 21:10
Show Gist options
  • Save mk0x9/1961433 to your computer and use it in GitHub Desktop.
Save mk0x9/1961433 to your computer and use it in GitHub Desktop.
def index
@rooms = Room.includes :user
result = []
@rooms.each do |room|
el1 = {}
el2 = {}
Room.column_names.each { |col| el1[col] = room.send col }
User.column_names.each { |col| el2[col] = room.user.send col }
result << el1.merge(user: el2)
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: result }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment