Created
March 10, 2011 06:16
-
-
Save topherfangio/863649 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
def create | |
if params[:member_id] and params[:title] | |
# Periods in a username will have been translated to underscores | |
member_id = params[:member_id].gsub('_', '.') | |
title = params[:title] | |
@member = Member.find(member_id) | |
@label = Label.new(:username => member_id, :title => title) | |
if @label.save | |
@label.reload | |
respond_to do |format| | |
format.json { render :json => @label, :status => :created and return } | |
end | |
else | |
respond_with :status => 406, :errors => @label.errors and return | |
end | |
end | |
respond_with :status => 406, :errors => [ :message => "member_id and title parameters must be provided" ] and return | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment