Skip to content
This repository has been archived by the owner on Apr 28, 2019. It is now read-only.

slug => is already taken redux #23

Open
Iteratix opened this issue Feb 5, 2014 · 4 comments
Open

slug => is already taken redux #23

Iteratix opened this issue Feb 5, 2014 · 4 comments

Comments

@Iteratix
Copy link

Iteratix commented Feb 5, 2014

This issue is still affecting our Wagon/Engine installs, using latest code.

Duplicate #16, but #16 is marked as closed and solved, but it is not for us. Also, comments in #16 indicate this is same for others.

Also, in locomotivecms/engine#804 others commented that it is not working for them either.

@felix-last
Copy link

We have the same issue. Always been deleting the templatized pages before pushing.

@mariosant
Copy link

I confirm that, we are having the same issue for snippets too!

@LouisSayers
Copy link

I'm seeing the same thing for handles as well as slugs :(

@LouisSayers
Copy link

K, I traced the problem for pages to PagesWriter#prepare. The problem can be summed up as follows:

self.pages                         # {handle: slug}
attributes['fullpage']             # slug
self.pages[attributes['fullpage']] # fail

So I'm guessing the appropriate thing is to instead have attributes['handle'] - but I'm not sure exactly what 'fullpage' is supposed to represent? and not sure if everything gets given a default handle?

For now I've implemented the inverse of the above comment to make my own system work:

 def prepare
        super
        self.new_pages, self.remote_translations = [], {}

        pages_by_slug = {} #added
        self.pages.map { |key,value| pages_by_slug[value.slug] = value } #added

        # set the unique identifier to each local page
        self.get(:pages, nil, true).each do |attributes|
          require 'pry';binding.pry
          page = pages_by_slug[attributes['fullpath'].dasherize] #modified to use pages_by_slug
          self.remote_translations[attributes['fullpath']] = attributes['translated_in']
          page._id = attributes['id'] if page
        end

        # assign the parent_id and the content_type_id to all the pages
        self.pages.values.each do |page|
          next if page.index_or_404?

          page.parent_id = page.parent._id
        end
      end

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

No branches or pull requests

4 participants