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

Already on GitHub? Sign in to your account

seeds #1910

Closed
markbrown4 opened this Issue Aug 28, 2012 · 4 comments

Comments

Projects
None yet
3 participants

Creating an engine instructs us to run seeds but If you change the title of any of the default pages they fail.

undefined method `update_attributes' for nil:NilClass
refinerycms-pages-2.0.8/db/seeds.rb:45

Owner

ugisozols commented Aug 28, 2012

@markbrown4 can you give a bit more specific steps to reproduce? Thanks.

Clean install
Change the title of 'Home' to 'Blah'
rails generate refinery:engine event title:string

bundle install
rails generate refinery:events
rake db:migrate
rake db:seed

Owner

ugisozols commented Aug 28, 2012

It's happening because of https://github.com/resolve/refinerycms/blob/master/pages/db/seeds.rb#L46. Each time you seed the db it's trying to find page called Home and update its slug.

@parndt @robyurkowski what do you think about this?

(Refinery.i18n_enabled? ? Refinery::I18n.frontend_locales : [:en]).each do |lang|
  I18n.locale = lang
  Refinery::Page.all.each do |page|
    page.update_attributes(:slug => page.title.parameterize)
  end
end

The downside of this is that it'll update slugs for all pages and not only the default ones. WDYT?

Owner

ugisozols commented Aug 28, 2012

One more option - don't do anything if it can't find Home, About or Page not found.

@parndt parndt closed this in 559014a Aug 29, 2012

parndt added a commit that referenced this issue Aug 29, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment