Skip to content

Commit 975b476

Browse files
authored
Fix syntax highlighting Github io page
1 parent e757f9a commit 975b476

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Or install it yourself as:
3737

3838
Back to example above, all you have to do is to mark `Product` as `actable` and all product type models as `acts_as :product`:
3939

40-
```Ruby
40+
```ruby
4141
class Product < ActiveRecord::Base
4242
actable
4343
belongs_to :store
@@ -67,7 +67,7 @@ end
6767
and add foreign key and type columns to products table as in a polymorphic relation.
6868
You may prefer using a migration:
6969

70-
```Ruby
70+
```ruby
7171
change_table :products do |t|
7272
t.integer :actable_id
7373
t.string :actable_type
@@ -76,7 +76,7 @@ end
7676

7777
or use shortcut `actable`
7878

79-
```Ruby
79+
```ruby
8080
change_table :products do |t|
8181
t.actable
8282
end
@@ -90,7 +90,7 @@ on parent table and they will be touched after submodel updates (You can use the
9090
Now `Pen` and `Book` **acts as** `Product`, i.e. they inherit `Product`s **attributes**,
9191
**methods** and **validations**. Now you can do things like these:
9292

93-
```Ruby
93+
```ruby
9494
Pen.create name: 'Penie!', price: 0.8, color: 'red'
9595
# => #<Pen id: 1, color: "red">
9696
Pen.where price: 0.8
@@ -119,14 +119,14 @@ Pen.first.info
119119

120120
On the other hand you can always access a specific object from its parent by calling `specific` method on it:
121121

122-
```Ruby
122+
```ruby
123123
Product.first.specific
124124
# => #<Pen ...>
125125
```
126126

127127
If you have to come back to the parent object from the specific, the `acting_as` returns the parent element:
128128

129-
```Ruby
129+
```ruby
130130
Pen.first.acting_as
131131
# => #<Product ...>
132132
```
@@ -139,7 +139,7 @@ Pen.where(...).actables
139139

140140
In `has_many` case you can use subclasses:
141141

142-
```Ruby
142+
```ruby
143143
store = Store.create
144144
store.products << Pen.create
145145
store.products.first
@@ -148,7 +148,7 @@ store.products.first
148148

149149
You can give a name to all methods in `:as` option:
150150

151-
```Ruby
151+
```ruby
152152
class Product < ActiveRecord::Base
153153
actable as: :producible
154154
end
@@ -169,7 +169,7 @@ Make sure you know what you are doing when overwriting `validate` or `autosave`
169169

170170
You can pass scope to `acts_as` as in `has_one`:
171171

172-
```Ruby
172+
```ruby
173173
acts_as :person, -> { includes(:friends) }
174174
```
175175

@@ -182,7 +182,7 @@ Make sure you know what you are doing when overwriting `polymorphic` option.
182182

183183
If your `actable` and `acts_as` models are namespaced, you need to configure them like this:
184184

185-
```Ruby
185+
```ruby
186186
class MyApp::Product < ApplicationRecord
187187
actable inverse_of: :product
188188
end
@@ -201,7 +201,7 @@ To use this library custom RSpec matchers, you must require the `rspec/acts_as_m
201201

202202
Examples:
203203

204-
```Ruby
204+
```ruby
205205
require "active_record/acts_as/matchers"
206206

207207
RSpec.describe "Pen acts like a Product" do

0 commit comments

Comments
 (0)