Skip to content

Instantly share code, notes, and snippets.

@bhserna
Created December 7, 2014 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhserna/64205209d808df07ff81 to your computer and use it in GitHub Desktop.
Save bhserna/64205209d808df07ff81 to your computer and use it in GitHub Desktop.
class EventsController < ApplicationController
def create
@event = Event.new(event_params)
if @event.valid_for_creation?
@event.save
redirect_to event_path
else
render :new
end
end
end
class Event < ActiveRecord::Base
def valid_for_creation?
add_errors(EventCreationValidatior.errors_for(self))
errors.emtpy?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment