Last active
August 29, 2015 14:14
-
-
Save jpotts18/27fbc3674811db987efa 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 DocumentsController < ApplicationController | |
before_action :set_document, only: [:show, :edit, :update, :destroy] | |
before_filter :load_folder | |
# GET /documents | |
# GET /documents.json | |
def index | |
@documents = documents.all | |
end | |
private | |
def load_folder | |
@folder = Folder.find(params[:folder_id]) | |
end | |
def documents | |
@folder ? @folder.documents : Document | |
end | |
# Use callbacks to share common setup or constraints between actions. | |
def set_document | |
@document = Document.find(params[:id]) | |
end | |
# Never trust parameters from the scary internet, only allow the white list through. | |
def document_params | |
params.require(:document).permit(:name, :text, :url, :user_id, :folder_id, :label_id) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks fine except that folder isn't defined as far as I can tell.
assuming. There's a @folder.