Skip to content

Instantly share code, notes, and snippets.

@sevenseacat
Created November 21, 2014 11:36
Show Gist options
  • Select an option

  • Save sevenseacat/7027219172faf789fc4f to your computer and use it in GitHub Desktop.

Select an option

Save sevenseacat/7027219172faf789fc4f to your computer and use it in GitHub Desktop.
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