Skip to content

Commit

Permalink
Merge pull request #240 from igorkasyanchuk/239-ino-files-seem-to-be-…
Browse files Browse the repository at this point in the history
…ignored

[Readme] Add example for adding content type to Marcel (#239)
  • Loading branch information
Mth0158 authored Feb 12, 2024
2 parents 18bde2d + 768e2c4 commit dd835e6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ end

### More examples

- Content type validation using symbols or regex. The symbol types must be registered by [`Marcel::EXTENSIONS`](https://github.com/rails/marcel/blob/main/lib/marcel/tables.rb) that's used by this gem to infer the full content type.
- Content type validation using symbols or regex.

```ruby
class User < ApplicationRecord
Expand All @@ -82,6 +82,12 @@ class User < ApplicationRecord
validates :avatar, content_type: /\Aimage\/.*\z/
end
```
Please note that the symbol types must be registered by [`Marcel::EXTENSIONS`](https://github.com/rails/marcel/blob/main/lib/marcel/tables.rb) that's used by this gem to infer the full content type.
Example code for adding a new content type to Marcel:
```ruby
# config/initializers/mime_types.rb
Marcel::MimeType.extend "application/ino", extensions: %w(ino), parents: "text/plain" # Registering arduino INO files
```

- Dimension validation with `width`, `height` and `in`.

Expand Down

0 comments on commit dd835e6

Please sign in to comment.