Project

cookbook

0.0
No release in over a year
Cookbook allows you to associate instructions with components in a cross referenced way. Good for cooking recipes or an instruction manual for DIY projects.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 2, < 3
>= 1.8, < 2
>= 4.8, < 5
>= 0
~> 2.1.0
>= 4.3, < 5
>= 1.4.2, < 2

Runtime

>= 3.3, < 4
>= 2.0, < 3
>= 6, < 7
>= 5, < 7
>= 5.1, < 6
>= 1.3, < 2
 Project Readme

Works Cited

Works Cited allows you to add a list of the works cited in ActiveRecord objects, to be formatted by a helper that can be added to relevant pages to format the citations like a bibliography.

Works Cited can be configured to use CanCanCan to authorize the editing of citations. This makes it easy for you to control access.

Installation

Add this line to your application's Gemfile:

gem 'works_cited'

And then execute:

$ bundle install

Then generate the migrations

$ rake cookbook:install:migrations
$ rake db:migrate

Configuration

You will need to add access for the people who should be authorized. Cookbook uses CanCanCan for authorization. Simply add the appropriate permissions to your ability.rb file:

class Ability
  include CanCan::Ability

  def initialize(user)
    user ||= User.new

    can :read, Cookbook::Use
    can :read, Recipe
    can :read, Ingredient

    return if user.new_record? # Anonymous Users leave

    # # We could have other rules in here, like:
    # can :manage, Cookbook::Use, use_of: { user_id: user.id }, use_in: { user_id: user.id }

    return unless user.admin? # Non Admin Users leave

    can :manage, Cookbook::Use
    can :manage, Recipe
    can :manage, Ingredient
  end
end

Usage

Make a model ready to accept uses, such as Recipe or Instructions

acts_as_use_of

Make a model a thing that gets used, such as Ingredient or Tool

acts_as_used_in

Add the helpers to the relevant views

= cookbook_uses_of @ingredient
-# OR
= cookbook_used_in @recipe

Add the fields to your instructional forms (e.g. Recipes)

= form_for(@recipe) do |f|
  = cookbook_fields f

Don't forget to add the controller concern to enable nested attributes with strong parameters

class RecipesController < ApplicationController
  include Cookbook::Params

  #...
    
  def recipe_params
    params.require(:recipe).permit(:name, :description, :serves, :meal, :instructions, cookbook_params('Recipe'))
  end
end

Contributing

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

License

Copyright (c) 2021 Loren Lundgren. See LICENSE.txt for further details.