Skip to content

Commit 9887ede

Browse files
author
Kyle d'Oliveira
committed
Merge pull request #1 from fimmtiu/patch-1
Typo fixes in the README.
2 parents 3616b29 + 0825380 commit 9887ede

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class CreatePictures < ActiveRecord::Migration
2929
end
3030
```
3131

32-
The problem with this approach is the `imageable_type` is a string (and by default it is 255 characters). This is a little rediculous. For comparison, if we had a state machine with X states, would be describe the states with strings `"State1", "State2", etc` or would be just enumerate the state column and make it an integer. This gem will make it so we can use an integer for the `imageable_type` column.
32+
The problem with this approach is that `imageable_type` is a string (and by default it is 255 characters). This is a little ridiculous. For comparison, if we had a state machine with X states, would we describe the states with strings `"State1", "State2", etc` or would we just enumerate the state column and make it an integer? This gem will allow us to use an integer for the `imageable_type` column.
3333

3434
## Installation
3535

@@ -49,7 +49,7 @@ Or install it yourself as:
4949

5050
The gem is pretty straightforward to use.
5151

52-
First, include the extensions module and add the `integer_type` option to the assocaitions that are going to be using this. (That way it will play nicely with polymorphic association you would rather the type remain as a string)
52+
First, include the extensions module and add the `integer_type` option to the associations that are going to be using this. (That way it will play nicely with polymorphic associations whose type you would rather leave as a string.)
5353
```ruby
5454
class Picture < ActiveRecord::Base
5555
include PolymorphicIntegerType::Extensions
@@ -76,9 +76,9 @@ PolymorphicIntegerType::Mapping.configuration do |config|
7676
end
7777
```
7878

79-
Note: The mapping here can start from whatever integer you wish, but I would advise not to use 0. The reason being that if you had a new class, for instance `Avatar`, and also wanted to use this polymorphic association but forgot to include it in the mapping, it would effectively get `to_i` called on it and stored in the database. `"Avatar".to_i == 0` so if your mapping included 0, this would create a weird bug.
79+
Note: The mapping here can start from whatever integer you wish, but I would advise not using 0. The reason being that if you had a new class, for instance `Avatar`, and also wanted to use this polymorphic association but forgot to include it in the mapping, it would effectively get `to_i` called on it and stored in the database. `"Avatar".to_i == 0`, so if your mapping included 0, this would create a weird bug.
8080

81-
If you want to migrate from a polymorphic association that is already a string you'll need to setup a migration (assuming sql for the time being. But this should be pretty straightforward)
81+
If you want to convert a polymorphic association that is already a string, you'll need to set up a migration. (Assuming SQL for the time being, but this should be pretty straightforward.)
8282
```ruby
8383
class PictureToPolymorphicIntegerType < ActiveRecord::Migration
8484

@@ -122,7 +122,7 @@ class PictureToPolymorphicIntegerType < ActiveRecord::Migration
122122
end
123123
```
124124

125-
Lastly, you will need to be careful of any place where you are doing raw sql queries with the string (`imageable_type = 'Employee'`). They should use the integer instead
125+
Lastly, you will need to be careful of any place where you are doing raw SQL queries with the string (`imageable_type = 'Employee'`). They should use the integer instead.
126126

127127

128128

0 commit comments

Comments
 (0)