Created
April 17, 2015 17:44
-
-
Save 8vius/df096526de244d4da3ee 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
# 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