test/dummy/app/controllers/users_controller.rb in csv_rails-0.4.1 vs test/dummy/app/controllers/users_controller.rb in csv_rails-0.5.0
- old
+ new
@@ -1,17 +1,17 @@
class UsersController < ApplicationController
def index
- @users = User
+ @users = User.includes(:groups)
respond_to do |format|
format.html
- format.csv { render csv: @users, fields: [:id, :name, :age] }
+ format.csv { render csv: @users, fields: [:id, :name, :age, :"groups.first.name"], without_header: true }
end
end
def sjis
- @users = User.all
+ @users = User.includes(:groups).all
respond_to do |format|
format.html
- format.csv { render csv: @users, fields: [:id, :name, :age], :encoding => 'SJIS'}
+ format.csv { render csv: @users, fields: [:id, :name, :age, :"groups.first.name"], encoding: 'SJIS' }
end
end
end