Skip to content

Instantly share code, notes, and snippets.

@8vius
Created April 17, 2015 17:44
Show Gist options
  • Save 8vius/df096526de244d4da3ee to your computer and use it in GitHub Desktop.
Save 8vius/df096526de244d4da3ee to your computer and use it in GitHub Desktop.
# app/controllers/documents_controller.rb
def new
@document = Document.new
end
def create
@document = current_user.documents.build(document_params)
if @document.save
render :new
else
render :new
end
end
# config/routes.rb
resources :documents, only: [:new, :create, :index]
# app/views/documents/new.html.haml
#document.create
%h2= t(".title")
= simple_form_for @document do |form|
= render partial: '/documents/form', object: form
.submit-field
= form.submit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment