Skip to content

Instantly share code, notes, and snippets.

@px-amaac
Created December 11, 2014 05:11
Show Gist options
  • Select an option

  • Save px-amaac/76dd985fbd2d0f771f7a to your computer and use it in GitHub Desktop.

Select an option

Save px-amaac/76dd985fbd2d0f771f7a to your computer and use it in GitHub Desktop.
vagrant@precise64:/vagrant/cins465-p7/tutorialcreator$ rails c
Loading development environment (Rails 4.1.2)
[1] pry(main)> Step
=> Step (call 'Step.connection' to establish a connection)
[2] pry(main)> Step.all
Step Load (7.1ms) SELECT "steps".* FROM "steps"
=> [#<Step id: 6, title: "step one", problem: "need a step", solution: "i made a step", tutorial_id: nil, created_at: "2014-12-09
05:39:05", updated_at: "2014-12-09 05:39:05">]
[3] pry(main)> @steps = Step.all
Step Load (1.4ms) SELECT "steps".* FROM "steps"
=> [#<Step id: 6, title: "step one", problem: "need a step", solution: "i made a step", tutorial_id: nil, created_at: "2014-12-09
05:39:05", updated_at: "2014-12-09 05:39:05">]
[4] pry(main)> @steps
=> [#<Step id: 6, title: "step one", problem: "need a step", solution: "i made a step", tutorial_id: nil, created_at: "2014-12-09
05:39:05", updated_at: "2014-12-09 05:39:05">]
[5] pry(main)> @step = @steps.first
=> #<Step id: 6, title: "step one", problem: "need a step", solution: "i made a step", tutorial_id: nil, created_at: "2014-12-09 0
5:39:05", updated_at: "2014-12-09 05:39:05">
[6] pry(main)> @step.sections
Section Load (1.1ms) SELECT "sections".* FROM "sections" WHERE "sections"."step_id" = ? [["step_id", 6]]
=> []
[7] pry(main)> @section = @step.sections.build
=> #<Section id: nil, step_id: 6, item_id: nil, item_type: nil, created_at: nil, updated_at: nil>
[8] pry(main)> @section
=> #<Section id: nil, step_id: 6, item_id: nil, item_type: nil, created_at: nil, updated_at: nil>
[9] pry(main)> @section = @step.sections.new
=> #<Section id: nil, step_id: 6, item_id: nil, item_type: nil, created_at: nil, updated_at: nil>
[12] pry(main)> @section
=> #<Section id: nil, step_id: 6, item_id: nil, item_type: nil, created_at: nil, updated_at: nil>
[13] pry(main)> @step
=> #<Step id: 6, title: "step one", problem: "need a step", solution: "i made a step", tutorial_id: nil, created_at: "2014-12-09 0
5:39:05", updated_at: "2014-12-09 05:39:05">
[14] pry(main)> @step.codeblocks
Codeblock Load (1.6ms) SELECT "codeblocks".* FROM "codeblocks" WHERE "codeblocks"."step_id" = ? [["step_id", 6]]
=> [#<Codeblock id: 7, code: "things are going on", description: "code stuff", created_at: "2014-12-09 07:53:51", updated_at: "201
4-12-09 07:53:51", step_id: 6>,
#<Codeblock id: 8, code: "class CodeblocksController < ApplicationController...", description: "test code", created_at: "2014-12-
09 07:54:38", updated_at: "2014-12-09 07:54:38", step_id: 6>,
#<Codeblock id: 13, code: "aoeuaoeu", description: "aoeuaeu", created_at: "2014-12-11 03:32:57", updated_at: "2014-12-11 03:32:57
", step_id: 6>]
[16] pry(main)> @codeblock = @step.codeblocks.first
=> #<Codeblock id: 7, code: "things are going on", description: "code stuff", created_at: "2014-12-09 07:53:51", updated_at: "2014
-12-09 07:53:51", step_id: 6>
[17] pry(main)> @section.item = @codeblock
=> #<Codeblock id: 7, code: "things are going on", description: "code stuff", created_at: "2014-12-09 07:53:51", updated_at: "2014
-12-09 07:53:51", step_id: 6>
[18] pry(main)> @section
=> #<Section id: nil, step_id: 6, item_id: 7, item_type: "Codeblock", created_at: nil, updated_at: nil>
[19] pry(main)> @section.save
(0.3ms) begin transaction
SQL (18.0ms) INSERT INTO "sections" ("created_at", "item_id", "item_type", "step_id", "updated_at") VALUES (?, ?, ?, ?, ?) [["
created_at", "2014-12-11 05:09:26.499952"], ["item_id", 7], ["item_type", "Codeblock"], ["step_id", 6], ["updated_at", "2014-12-11
05:09:26.499952"]]
(7.3ms) commit transaction
=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment