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

finding a page

nirnanaaa edited this page Aug 30, 2013 · 2 revisions

There are several methods to find a page.

I am assuming, that you use Page as the GollumRails::Page subclass and page as an instance of this class.

Find by name

Finding a page by name is very easy:

Page.find('home')

# => #<Page:0x007ff90b784270 @gollum_page=#<Gollum::Page:70353807993320 home (markdown) @wiki="/Users/nirnanaaa/code/test/.git">, @name="home", @content="# ...

Finding by other attributes(currently only name supported)

Find a page by an attribute:

Page.find_by_name('home')
# => #<Page:0x007ff90b784270 @gollum_page=#<Gollum::Page:70353807993320 home (markdown) @wiki="/Users/nirnanaaa/code/test/.git">, @name="home", @content="# ...

Find a page or create it.

Page.find_or_initialize_by_name('home', commit)
#<Page:0x007fb9b9297190 @gollum_page=#<Gollum::Page:70217826072220 home (markdown) @wiki="/Users/nirnanaaa/code/test.git">, @name="home", @content=".", @format=:markdown>

Page.find_or_initialize_by_name('home',commit)
# => #<GollumRails::Page:0x007f98fd992c88 @format=:markdown, @name="home", @content=".", @commit={:name=>"Mosny", :message=>"Added home page", :email=>"mosny@zyg.li"}, @validation_context=nil, @errors=#<ActiveModel::Errors:0x007f98fb838a60 @base=#<GollumRails::Page:0x007f98fd992c88 ...>, @messages={}>, @gollum_page=#<Gollum::Page:70147516155540 home (markdown) @wiki="/Users/nirnanaaa/code/test.git">>

Find a page by a specific version

Page.find('home', 'b64d34e0bd159e2e209aaa5cb7cccac003f37994')
#=> #<Page:0x007ffb131c0898 @gollum_page=#<Gollum::Page:70358166851060 page (markdown) @wiki="/Users/nirnanaaa/code/test.git">, @name="page", @content=".", @format=:markdown>
Clone this wiki locally