+ else
+ render :action => 'edit'
+ end
+ end
+
+ def edit
+ @title= 'Edit diary entry'
+ @diary_entry = DiaryEntry.find(params[:id])
+
+ if @user != @diary_entry.user
+ redirect_to :controller => 'diary_entry', :action => 'view', :id => params[:id]
+ elsif params[:diary_entry]
+ @diary_entry.title = params[:diary_entry][:title]
+ @diary_entry.body = params[:diary_entry][:body]
+ @diary_entry.latitude = params[:diary_entry][:latitude]
+ @diary_entry.longitude = params[:diary_entry][:longitude]
+
+ if @diary_entry.save
+ redirect_to :controller => 'diary_entry', :action => 'view', :id => params[:id]
+ end
+ end
+ end
+
+ def comment
+ @entry = DiaryEntry.find(params[:id])
+ @diary_comment = @entry.diary_comments.build(params[:diary_comment])
+ @diary_comment.user = @user
+ if @diary_comment.save
+ Notifier::deliver_diary_comment_notification(@diary_comment)
+ redirect_to :controller => 'diary_entry', :action => 'view', :display_name => @entry.user.display_name, :id => @entry.id
+ else
+ render :action => 'view'