Move categories with command line

Thanks. It took me a while to figure out what was meant by “a way to get your categories”, but realised it probably was the “where” clause of a SQL statement. Though I had no idea what the table names or column names were, but managed to find them with the SQL statements noted in the post about the Data Model.

So, I ended up with this,

parent=Category.find_by_slug('csgnet') subs=Category.where('slug like “csg1%”').update_all(parent_category_id: parent.id)

which moves all categories starting with the text “csg1” into the category “csgnet”, where “slug” is the column name in the table of categories. The table name is called “category”, I think.

1 Like