diff --git a/README.md b/README.md index 7132637..f4c8e58 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ The gem is written with performance in mind. It was developed to support the DAG Again using the forum application as an example, one would have messages in a hierarchy with the additional ability of the message to reference each other. Querying could then e.g. look like this: -``` +```ruby # Fetch a root message with a specific subject. message = Message.hierarchy_roots.where(subject: 'Some bogus') @@ -64,7 +64,7 @@ TypedDag needs two AR models to be configured as the nodes and edges of the DAG. To avoid having to configure TypedDag twice, in the node and in the edge AR model, configuration is done in a rails initializer. In your rails app, add a file to `config/initializers`. -``` +```ruby # /config/initializers/typed_dag.rb # configuration for Relation/Message TypedDag::Configuration.set edge_class_name: 'Relation', @@ -170,7 +170,7 @@ The edge's table needs to be created containing at least the following columns ( A migration to create such a table could look like this: -``` +```ruby def change create_table :edges do |t| t.references :from, null: false @@ -200,7 +200,7 @@ There are no requirements on the node's table. When migrating from a different library, the details of course depend on the library used. If it is one of the many having a `parent_id` column on the node table, one would first have to create the edge table as outlined above and then add a SQL statement like this: -``` +```ruby ActiveRecord::Base.connection.execute <<-SQL INSERT INTO edges (from_id, to_id, hierarchy) @@ -213,7 +213,7 @@ When migrating from a different library, the details of course depend on the lib This will create all direct edges. Using -``` +```ruby Node.rebuild_dag! ```