Ticket #83: patch.diff

File patch.diff, 1.6 kB (added by novaa, 2 years ago)

the bugfix itself

  • trunk/examples/blog.rb

     
    6262            render :add 
    6363        end 
    6464        def post 
    65             post = Post.create :title => input.post_title, :body => input.post_body, 
    66                                :user_id => @state.user_id 
    67             redirect View, post 
     65            unless @state.user_id.blank? 
     66                post = Post.create :title => input.post_title, :body => input.post_body, 
     67                                   :user_id => @state.user_id 
     68                redirect View, post 
     69            end 
    6870        end 
    6971    end 
    7072 
     
    9698        end 
    9799      
    98100        def post 
    99             @post = Post.find input.post_id 
    100             @post.update_attributes :title => input.post_title, :body => input.post_body 
    101             redirect View, @post 
     101            unless @state.user_id.blank? 
     102                @post = Post.find input.post_id 
     103                @post.update_attributes :title => input.post_title, :body => input.post_body 
     104                redirect View, @post 
     105            end 
    102106        end 
    103107    end 
    104108      
     
    219223          input :name => 'post_username', :type => 'text'; br 
    220224          label 'Comment', :for => 'post_body'; br 
    221225          textarea :name => 'post_body' do; end; br 
    222           input :type => 'hidden', :name => 'post_id', :value => post.id 
     226          input :type => 'hidden', :name => 'post_id', :value => @post.id 
    223227          input :type => 'submit' 
    224228        end 
    225229    end