Created
September 22, 2008 17:59
-
-
Save piclez/12073 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Galleries < Application | |
before :login_required, :exclude => [:index, :show] | |
def index | |
# DM associations bug? | |
@galleries = User.first(:login => params[:login]).galleries | |
#@galleries = Gallery.all | |
display @galleries | |
end | |
# AIR | |
def get_user_galleries | |
provides :xml | |
if current_user | |
@galleries = current_user.galleries | |
display @galleries | |
end | |
end | |
def show | |
@gallery = Gallery.get(params[:id]) | |
@page_title = @gallery.title | |
raise NotFound unless @gallery | |
display @gallery | |
end | |
def new | |
only_provides :html | |
@gallery = Gallery.new | |
render | |
end | |
def edit | |
only_provides :html | |
@gallery = Gallery.get(params[:id]) | |
raise NotFound unless @gallery | |
render | |
end | |
def create | |
@gallery = Gallery.new(params[:gallery]) | |
@gallery.user = current_ma_user | |
if @gallery.save | |
redirect url(:galleries, current_ma_user) | |
else | |
render :new | |
end | |
end | |
def update | |
@gallery = Gallery.get(params[:id]) | |
raise NotFound unless @gallery | |
if @gallery.update_attributes(params[:gallery]) || [email protected]? | |
#redirect url(:gallery, :login => current_ma_user, :id => params[:id]) | |
redirect url(:galleries, current_ma_user) | |
else | |
raise BadRequest | |
end | |
end | |
def destroy | |
@gallery = Gallery.get(params[:id]) | |
raise NotFound unless @gallery | |
if @gallery.destroy | |
redirect url(:galleries, current_ma_user) | |
else | |
raise BadRequest | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment