Skip to content

Instantly share code, notes, and snippets.

@topherfangio
Created March 10, 2011 06:16
Show Gist options
  • Save topherfangio/863649 to your computer and use it in GitHub Desktop.
Save topherfangio/863649 to your computer and use it in GitHub Desktop.
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