Skip to content

Instantly share code, notes, and snippets.

@thomasmaas
Created February 12, 2016 20:55
Show Gist options
  • Save thomasmaas/be597dc43b48444888b8 to your computer and use it in GitHub Desktop.
Save thomasmaas/be597dc43b48444888b8 to your computer and use it in GitHub Desktop.
validation issue
casaschool/src/casaschool master ✗ 7h22m ⚑ ◒
▶ rails c
Loading development environment (Rails 4.2.5.1)
[1] pry(main)> group2 = Group.new
=> #<Group:0x007fb386d8c188 id: nil, slug: nil, description: nil, created_at: nil, updated_at: nil, email: nil, position: 0, page_id: nil, section_id: nil, parent: nil>
[2] pry(main)> group2.name = 'name'
=> "name"
[3] pry(main)> group2.save!
(0.4ms) BEGIN
(0.3ms) ROLLBACK
ActiveRecord::RecordInvalid: Validation failed: Name can't be blank
from /Users/thomasmaas/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.5.1/lib/active_record/validations.rb:79:in `raise_record_invalid'
[4] pry(main)> exit
casaschool/src/casaschool master ✗ 7h23m ⚑ ◒
▶ rails c
Loading development environment (Rails 4.2.5.1)
[1] pry(main)> reload!
Reloading...
=> true
[2] pry(main)> group2 = Group.new
=> #<Group:0x007fe21325a8a8 id: nil, slug: nil, description: nil, created_at: nil, updated_at: nil, email: nil, position: 0, page_id: nil, section_id: nil, parent: nil>
[3] pry(main)> group2.name = 'name'
=> "name"
[4] pry(main)> group2.save!
(0.4ms) BEGIN
Group Exists (1.5ms) SELECT 1 AS one FROM "groups" INNER JOIN "friendly_id_slugs" ON "friendly_id_slugs"."sluggable_id" = "groups"."id" AND "friendly_id_slugs"."sluggable_type" = $1 WHERE ("groups"."id" IS NOT NULL) AND "groups"."slug" = 'name' LIMIT 1 [["sluggable_type", "Group"]]
Group Exists (0.7ms) SELECT 1 AS one FROM "groups" INNER JOIN "friendly_id_slugs" ON "friendly_id_slugs"."sluggable_id" = "groups"."id" AND "friendly_id_slugs"."sluggable_type" = $1 WHERE ("groups"."id" IS NOT NULL) AND ("friendly_id_slugs"."sluggable_type" = 'Group' AND "friendly_id_slugs"."slug" = 'name') LIMIT 1 [["sluggable_type", "Group"]]
Group Load (0.9ms) SELECT "groups".* FROM "groups" WHERE (groups.position IS NOT NULL) AND (1 = 1) ORDER BY groups.position DESC LIMIT 1
SQL (0.6ms) INSERT INTO "groups" ("created_at", "updated_at", "position") VALUES ($1, $2, $3) RETURNING "id" [["created_at", "2016-02-12 20:46:54.204820"], ["updated_at", "2016-02-12 20:46:54.204820"], ["position", 31]]
SQL (0.8ms) INSERT INTO "group_translations" ("locale", "name", "slug", "group_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id" [["locale", "en"], ["name", "name"], ["slug", "name-87833139-5124-44f9-a4fe-fee397009f0e"], ["group_id", 40], ["created_at", "2016-02-12 20:46:54.223018"], ["updated_at", "2016-02-12 20:46:54.223018"]]
FriendlyId::Slug Load (0.6ms) SELECT "friendly_id_slugs".* FROM "friendly_id_slugs" WHERE "friendly_id_slugs"."sluggable_id" = $1 AND "friendly_id_slugs"."sluggable_type" = $2 ORDER BY "friendly_id_slugs".id DESC LIMIT 1 [["sluggable_id", 40], ["sluggable_type", "Group"]]
SQL (0.5ms) DELETE FROM "friendly_id_slugs" WHERE "friendly_id_slugs"."sluggable_id" = $1 AND "friendly_id_slugs"."sluggable_type" = $2 AND "friendly_id_slugs"."slug" = $3 [["sluggable_id", 40], ["sluggable_type", "Group"], ["slug", "name-87833139-5124-44f9-a4fe-fee397009f0e"]]
SQL (1.2ms) INSERT INTO "friendly_id_slugs" ("sluggable_id", "sluggable_type", "slug", "created_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["sluggable_id", 40], ["sluggable_type", "Group"], ["slug", "name-87833139-5124-44f9-a4fe-fee397009f0e"], ["created_at", "2016-02-12 20:46:54.260765"]]
(1.2ms) COMMIT
=> true
[5] pry(main)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment