|
Revision 4228, 1.0 kB
(checked in by david, 2 years ago)
|
More work later
|
| Line | |
|---|
| 1 |
class EntriesController < ApplicationController |
|---|
| 2 |
before_filter :set_workspace |
|---|
| 3 |
|
|---|
| 4 |
def index |
|---|
| 5 |
@entries = @workspace.entries.find(:all) |
|---|
| 6 |
end |
|---|
| 7 |
|
|---|
| 8 |
def show |
|---|
| 9 |
@entry = find_entry |
|---|
| 10 |
end |
|---|
| 11 |
|
|---|
| 12 |
def new |
|---|
| 13 |
@entry = Entry.new |
|---|
| 14 |
end |
|---|
| 15 |
|
|---|
| 16 |
def create |
|---|
| 17 |
@entry = @workspace.entries.create(params[:entry]) |
|---|
| 18 |
|
|---|
| 19 |
respond_to do |type| |
|---|
| 20 |
type.js |
|---|
| 21 |
type.atom do |
|---|
| 22 |
headers["Location"] = entry_url(:id => @entry) |
|---|
| 23 |
render :nothing => true, :status => "201 Created" |
|---|
| 24 |
end |
|---|
| 25 |
end |
|---|
| 26 |
end |
|---|
| 27 |
|
|---|
| 28 |
def edit |
|---|
| 29 |
@entry = find_entry |
|---|
| 30 |
end |
|---|
| 31 |
|
|---|
| 32 |
def update |
|---|
| 33 |
@entry = @workspace.entries.update(params[:entry][:id], params[:entry]) |
|---|
| 34 |
end |
|---|
| 35 |
|
|---|
| 36 |
def destroy |
|---|
| 37 |
@workspace.entries.destroy(params[:id]) |
|---|
| 38 |
end |
|---|
| 39 |
|
|---|
| 40 |
def feed |
|---|
| 41 |
@entries = @workspace.entries.find(:all, :limit => 25) |
|---|
| 42 |
render :layout => false |
|---|
| 43 |
end |
|---|
| 44 |
|
|---|
| 45 |
private |
|---|
| 46 |
def set_workspace |
|---|
| 47 |
@workspace = Workspace.find(:first) |
|---|
| 48 |
end |
|---|
| 49 |
|
|---|
| 50 |
def find_entry(id = params[:id]) |
|---|
| 51 |
@workspace.entries.find(id) |
|---|
| 52 |
end |
|---|
| 53 |
end |
|---|