Created
January 19, 2011 21:00
-
-
Save Gregg/786858 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # 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