Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trouble with put_section #47

Closed
holden opened this issue Oct 29, 2012 · 2 comments
Closed

trouble with put_section #47

holden opened this issue Oct 29, 2012 · 2 comments

Comments

@holden
Copy link

holden commented Oct 29, 2012

I've been having difficulty with the put_section() method.

get_section works fine.

@page = Page.find(params[:id])

if params[:section]
   section = @page.wiki.get_section(params[:section])
   @page.section_content = section
end

But when I try to do:

@page = Page.find(params[:id])

if params[:section]
  wiki = @page.wiki
  wiki.put_section(params[:section],params[:section_content])
  @page.content = wiki.to_wiki
end

#normal rails save here...

It does nothing. Also tried to get it to work in the console with no luck. ;-(

Wiki method in model

  def wiki
    data = WikiParser.new(:data => content)
  end
@nricciar
Copy link
Owner

When you used put_section did you include the heading in the content you inserted? For example...

== section1 ==
test

== section2 ==
hello world

== section3 ==
whoo

get_section("section2") will leave you with...

== section2 ==
hello world

To change said section you would just...

put_section("section2", "== new heading title ==\n new content\n")

calling to_wiki should then leave you with the following output...

== section1 ==
test

== new heading title ==
new content

== section3 ==
whoo

@holden
Copy link
Author

holden commented Oct 29, 2012

ah, got it. That's why i couldn't get it to work in the console. And my form I wasn't passing the proper section id... Thanks.

@holden holden closed this as completed Oct 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants