Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tidying up code

  • Loading branch information...
commit d8b3550acaae983c3d0faf8f1eb4da30f0da1eb5 1 parent 20f2c84
@bthesorceror authored
Showing with 5 additions and 31 deletions.
  1. +3 −31 app/controllers/tasks_controller.rb
  2. +2 −0  app/models/task.rb
View
34 app/controllers/tasks_controller.rb
@@ -3,9 +3,7 @@ class TasksController < ApplicationController
accept_key_auth :feed, :destroy
- before_filter :require_logged, :except => [:feed, :destroy]
- before_filter :require_key, :only => [:feed]
- before_filter :require_logged_or_key, :only => [:destroy]
+ before_filter :require_login
def index
@tasks = User.current.tasks
@@ -22,7 +20,7 @@ def create
end
def destroy
- task = @current_user.tasks.find(params[:id])
+ task = User.current.tasks.find(params[:id])
task.destroy
if params[:key]
render :text => "Task Removed!", :status => 200
@@ -34,34 +32,8 @@ def destroy
def feed
response.headers["Content-Type"] = "application/xml; charset=utf-8"
- @tasks = @current_user.tasks
+ @tasks = User.current.tasks
render :layout => false
end
-
- private
-
- def require_logged
- @current_user = User.current
- unless @current_user.logged?
- redirect_to root_path
- end
- end
-
- def require_key
- @key = params[:key]
- @current_user = User.find_by_rss_key(@key) if @key
- unless @current_user
- render :inline => 'Invalid Key'
- return false
- end
- end
-
- def require_logged_or_key
- if params[:key]
- require_key
- else
- require_logged
- end
- end
end
View
2  app/models/task.rb
@@ -1,6 +1,8 @@
class Task < ActiveRecord::Base
unloadable
+ validates_presence_of :body, :message => "cannot be blank"
+
def to_s
self.body
end
Please sign in to comment.
Something went wrong with that request. Please try again.