export CSV by rails
I will not save a file, just make it downloaded by Tempfile.
I will not use database table, of course.
This is how my form looks (in new page)
config/routes.rb file
resources :accounts, only: [:new, :create]
app/views/accounts/new.html.erb file
<%= form_with url: accounts_path, local: true do |f| %>
<%= f.text_area :names, rows: 10, required: true %>
<p>Add account names separated by newline.</p>
<%= f.submit 'Export CSV' %>
<% end %>
When the form is submitted, it triggers create action. Form submit of form_with makes POST request to accounts_path with parameters. And rails syntax resources :accounts makes create action of accounts controller triggered by that POST request.
And this is not a model backed form. Sometimes simple things look difficult or not possible because the other complicated things look too easy. ActiveRecord is not needed (something like @account in the...