Table from Rails 3
Method 1, csv output from the index as explained here
To the controller, add format.csv like below:
[ruby]
respond_to do |format|
format.html # index.html.erb
format.json { render json: @people }
format.csv
end
[/ruby]
And create a view, people.csv.erb with something like this:
[plain]<% @people.each do |p| > <= raw “#{p.first_name} #{p.last_name}” > < end %>[/plain]
When you want a quick table, add extension “.csv” after the name of the view in the URL. If you add this extension before the question mark, you can also output search results.
[text]
localhost:3000/people<span style="color: #33cccc;">.csv</span>
localhost:3000/search/people<span style="color: #33cccc;">.csv</span>?utf8=✓&q=71..80&commit=find
[/text]
Method 2, yaml dump in the console
rails c y People.find([1,2,3], select=>[id, name])
Method3, using table_print from the console
Install table_print
From the console type:
[shell]
tp People.where(id: 3..14), :id, :name => {:width => 60}
[/shell]