Created
November 21, 2014 11:36
-
-
Save sevenseacat/7027219172faf789fc4f 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
| class ProjectsController < ApplicationController | |
| def create | |
| @project = Project.new(project_params) | |
| # authorization checking - this depends on the library you're using | |
| # this example is for cancan | |
| authorize! :create, @project | |
| if @project.save | |
| redirect_to projects_path, notice: 'Yay!' | |
| else | |
| # Do bad stuff | |
| # This will re-render the form, and in theory show the error messages on the @project object | |
| render :new | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment