examples/app/wikore/src/controller.rb in Pistos-ramaze-2009.04.08 vs examples/app/wikore/src/controller.rb in Pistos-ramaze-2009.06.12

- old
+ new

@@ -16,30 +16,32 @@ @version = false end end end -class PageController < Ramaze::Controller +class Pages < Ramaze::Controller map '/page' - helper :aspect - def create + redirect_referer unless request.post? + change "Created Page '%s'" do |title, text| Page.create(:title => title, :text => text, :version => 1) - redirect R(MainController, title) + redirect MainController.r(:/, title) end end def save + redirect_referer unless request.post? + change "Updated Page '%s'" do |title, text| page = Page[:title => title] page.backup page.text = text page.version += 1 page.save - redirect R(MainController, title) + redirect MainController.r(:/, title) end end def delete(title) page = Page[:title => title] @@ -58,23 +60,19 @@ end def revert(title) page = Page[:title => title] page.revert - redirect R(MainController, title) + redirect MainController.r(:/, title) end - before :create, :save do - redirect_referer unless request.post? - end - private def change(message, redirect_to = '/') if title = request['title'] and text = request['text'] yield(title, text) message % title end - redirect(R(MainController, redirect_to)) + redirect MainController.r(redirect_to) end end