Skip to content

Instantly share code, notes, and snippets.

@dmilith
Created December 8, 2008 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmilith/33524 to your computer and use it in GitHub Desktop.
Save dmilith/33524 to your computer and use it in GitHub Desktop.
about.html.haml:
= throw_content :main_pl do
%br
- if @admin
= "Tutaj proszę wprowadzić tekst formatowany:"
%script{ :type => "text/javascript" }
$(document).ready(pocalujmniewdupe);
pocalujmniewdupe();
= form_for :text, :class => :text, :action => url( :action => :about, :method => :post ) do
%textarea{ :name => :content, :style => "width:100%; height:20em;" }
= @content.about_content
%div{ :style => "margin-top: 25px;" }
= "Podgląd wygenerowanej treści na stronie:"
= submit "Aktualizuj treść strony"
%fieldset
.generated_content= @generated_content
- else
.generated_content= @generated_content
%br
def about
if request.get?
if Content.count == 0
@content = Content.new( :about_content => "h1. O mnie." )
else
@content = Content.find(:first)
end
Merb.logger.debug request.inspect
Merb.logger.debug request.get?
Merb.logger.debug request.post?
render
else #request.post?
Merb.logger.debug request.inspect
Merb.logger.debug request.get?
Merb.logger.debug request.post?
@content = Content.find(:first)
@content.about_content = params[:content]
Merb.logger.info "\n\nABOUT POST: " + @content.about_content.inspect if $debug
@content.save!
end
@generated_content = @content.about_content
Merb.logger.info "\n\nABOUT UPDATE GENERATED:\n\n" + @generated_content if $debug
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment