Skip to content

Instantly share code, notes, and snippets.

@Gregg
Created January 19, 2011 21:00
Show Gist options
  • Select an option

  • Save Gregg/786858 to your computer and use it in GitHub Desktop.

Select an option

Save Gregg/786858 to your computer and use it in GitHub Desktop.
# You know REST... yeah... This is not RESTful
class UsersController < ApplicationController
def subscribe_mailing_list
current_user.subscribe(params[:mailing_list])
redirect_to users_path, :notice => "You've been subscribed"
end
def unsubscribe_mailing_list
current_user.unsubscribe(params[:mailing_list])
redirect_to users_path, :notice => "You have been unsubscribed"
end
end
# Would be better off doing:
class SubscriptionsController < ApplicationController
def create
current_user.subscribe(params[:id])
redirect_to users_path, :notice => "You've been subscribed"
end
def destroy
current_user.unsubscribe(params[:id])
redirect_to users_path, :notice => "You have been unsubscribed"
end
end
# It's just better form.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment