Skip to content

Commit abdc019

Browse files
Merge pull request #173 from Chrisgo-75/rails7_unknown_format_fix
Edit README troubleshooting section with a new section about Rails 7 …
2 parents 3c3cbd9 + 5adafab commit abdc019

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,26 @@ If you are using turbolinks, you may need to disable turbolinks when you link to
419419
link_to 'Download spreadsheet', path_to_sheet, data: {turbolinks: false}
420420
```
421421

422+
### Rails 7 Unknown Format
423+
424+
In Rails 7, if you get an error of "Unknown Format" you may need to add `(format: "xlsx")` to the named route.
425+
426+
A clue to the "format" that Rails is responding with is to look at your log file or console after you click the HTML link or submit your form. You should see `Processing by Controller#action as XLSX`.
427+
428+
#### Code Examples
429+
430+
Scenario 1 - HTML Link within index.html.erb
431+
432+
```ruby
433+
link_to "Download as Excel", my_named_route_path(format: "xlsx")
434+
```
435+
436+
Scenario 2 - Using form_with()
437+
438+
```ruby
439+
form_with method: :post, url: my_named_route_path(format: :xlsx) do |f|
440+
```
441+
422442
### What to do
423443

424444
If you are having problems, try to isolate the issue. Use the console or a script to make sure your data is good. Then create the spreadsheet line by line without Axlsx-Rails to see if you are having caxlsx problems. If you can manually create the spreadsheet, create an issue and we will work it out.

0 commit comments

Comments
 (0)