Add a new page-part to all existing pages?

閲覧: 161 回
最初の未読メッセージにスキップ

Peaceand

未読、
2012/07/31 6:51:202012/07/31
To: refine...@googlegroups.com
Hi,
I've got a nice site set up and working on Refinery 2-0-stable, but my design has changed slightly and I want to include a new page-part on every page.
Now I could do this manually through the web interface, but there are >70 pages full of content.

Does anybody have a suggestion for how to automate this? It's just a one-off process so it doesn't have to be elegant!

I've already edited the pages.rb initializer, so the new page-parts will be included on all new pages.

Thanks in advance,
Patrick

Rob Yurkowski

未読、
2012/07/31 8:37:242012/07/31
To: refine...@googlegroups.com
--
You received this message because you are subscribed to the Google
Groups "Refinery CMS" group.
To post to this group, send email to refine...@googlegroups.com
To unsubscribe from this group, send email to
refinery-cms...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/refinery-cms?hl=en
 
http://www.refinerycms.com

Peaceand

未読、
2012/07/31 11:46:572012/07/31
To: refine...@googlegroups.com
Hi Rob,
Thanks for that, it looks perfect, but I can't get it to work. I'm not very familiar with the rails console, but it seems to be a syntax problem? Possibly because I'm using Rails 3.6.2 ?

1.8.7 :063 > Refinery::Page.all.map do {|p| p.parts.create(:title => "Side Quote 1", :position => 4) }
1.8.7 :064?>  

And then nothing happens...so I'm guessing that ? appended means there was an error.

My poking around makes me think the parts object doesn't exist for my page objects - but obviously this can't be the case as I have existing page-parts.

This is the output I get when listing properties of one of the pages:

1.8.7 :061 > Refinery::Page.last
  Refinery::Page Load (1.0ms)  SELECT "refinery_pages".* FROM "refinery_pages" ORDER BY "refinery_pages"."id" DESC LIMIT 1
  Refinery::Page::Translation Load (0.8ms)  SELECT "refinery_page_translations".* FROM "refinery_page_translations" WHERE "refinery_page_translations"."refinery_page_id" = 39
 => #<Refinery::Page id: 39, parent_id: 36, path: nil, slug: "third-level-3", show_in_menu: true, link_url: "", menu_match: nil, deletable: true, draft: false,
 skip_to_first_child: false, lft: 22, rgt: 23, depth: 3, view_template: nil, layout_template: nil, created_at: "2012-07-26 09:16:55", updated_at: "2012-07-26 09:16:55">


Any idea what have I done wrong?

Thanks,
Patrick



On Tuesday, July 31, 2012 1:37:24 PM UTC+1, Rob Yurkowski wrote:
On 2012-07-31, at 6:51 AM, Peaceand wrote:

Hi,
I've got a nice site set up and working on Refinery 2-0-stable, but my design has changed slightly and I want to include a new page-part on every page.
Now I could do this manually through the web interface, but there are >70 pages full of content.

Does anybody have a suggestion for how to automate this? It's just a one-off process so it doesn't have to be elegant!

I've already edited the pages.rb initializer, so the new page-parts will be included on all new pages.

Thanks in advance,
Patrick

--
You received this message because you are subscribed to the Google
Groups "Refinery CMS" group.
To post to this group, send email to refine...@googlegroups.com
To unsubscribe from this group, send email to

Rob Yurkowski

未読、
2012/07/31 11:51:102012/07/31
To: refine...@googlegroups.com
Hey, Patrick --

That might be an error in the guide; remove the word 'do'.

Sent from my iPhone

Peaceand

未読、
2012/07/31 12:04:042012/07/31
To: refine...@googlegroups.com
Excellent, that was it.

For the sake of anybody who comes across this later, the final solution I used was:

Refinery::Page.all.map {|p| p.parts.create(:title => "Side Quote 1", :position => 1) unless p.parts.exists?(:title => "Side Quote 1") }

Thanks Rob!

Patrick
全員に返信
投稿者に返信
転送
新着メール 0 件