Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with seeds.rb file #1

Open
kgish opened this issue Jun 21, 2015 · 3 comments
Open

Problems with seeds.rb file #1

kgish opened this issue Jun 21, 2015 · 3 comments
Assignees

Comments

@kgish
Copy link

kgish commented Jun 21, 2015

After following instructions in your new book deciding just to use the seeds file instead of the humongous sql file, I get the following errors:

 $ rake db:seed
(in /home/kiffin/projects/wikicat)
rake aborted!
ActiveRecord::RecordNotUnique: Mysql2::Error: Duplicate entry '1282' for key 'PRIMARY': INSERT INTO `categories` (`cat_id`, `cat_title`, `cat_pages`, `cat_subcats`, `cat_files`, `created_at`, `updated_at`) VALUES (1282, 'Sports', 42, 41, 0, '2015-06-21 15:02:31', '2015-06-21 15:02:31')

and later after having removed the duplicate line:

 $ rake db:seed
(in /home/kiffin/projects/wikicat)
rake aborted!
NameError: undefined local variable or method `cl_to' for main:Object
/home/kiffin/projects/wikicat/db/seeds.rb:68:in `<top (required)>'

On line 68 there is a typo: cl_to needs to be changed to :cl_to

And then duplicate line:

ActiveRecord::RecordNotUnique: Mysql2::Error: Duplicate entry '157090' for key 'PRIMARY': INSERT INTO `categories` (`cat_id`, `cat_title`, `cat_pages`, `cat_subcats`, `cat_files`, `created_at`, `updated_at`) VALUES (157090, 'History', 59, 31, 0, '2015-06-21 15:13:57', '2015-06-21 15:13:57')

also needs to be removed.

And then finally:

ActiveRecord::RecordNotUnique: Mysql2::Error: Duplicate entry '275726' for key 'PRIMARY': INSERT INTO `categories` (`cat_id`, `cat_title`, `cat_pages`, `cat_subcats`, `cat_files`, `created_at`, `updated_at`) VALUES (275726, 'Science', 72, 34, 0, '2015-06-21 15:17:47', '2015-06-21 15:17:47')
@hiromipaw
Copy link
Owner

Hello,
Sorry about that. I had some duplicates in the seeds. I have now fixed it and you can pull and run:

$ rake db:setup

I hope this helps and thanks for reaching out.

@hiromipaw hiromipaw self-assigned this Jun 23, 2015
@marr
Copy link

marr commented Nov 9, 2015

I am following along with the book as well and notice that GraphController created on page 52 of the printed book assumes that the cat_title field in our db is ALL_CAPS, with this line:

  @category = Category.where(:cat_title => cat.capitalize).first

In seeds.rb they are title cased. What strategy would you like a PR for, capitalizing the category title in seeds.rb. Or, removing maybe force-lowercasing the param and WHERE condition?

@marr
Copy link

marr commented Nov 9, 2015

I may have spoke too soon, but I am still not sure why that controller works when the cat_title data is title case but the where above is expecting it to be capitalized.

My response has "sciences" as the root element too, which is also confusing:

    "sciences": [
        {
            "sub_category": "_%0Ascientists"
        },
        {
            "sub_category": "method%0Ascientific_method"

Seems to me like there might be something missing from the serializer. In seeds.rb, the cl_to values are newline separated, so for example when I hit /graph/culture, i'd expect that to show up:

Link.create(:cl_from => 1489599, :cl_to => "Sports", :cl_sortkey => "CULTURE\nSPORTS CULTURE",
            :cl_timestamp => "2005-04-29 10:32:42", :cl_sortkey_prefix => "Culture", :cl_collation => "uppercase",
            :cl_type => "subcat")

but it doesnt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants