Giter Site home page Giter Site logo

favourite_object's Introduction

favourite_object

A dropin utility that adds favourites functionality to any rails application. But simpling include a partial you can add a favourite button to any object.

Install:

gem 'favourite_object'
rails g favourite_object:install
rake db:migrate

Mount inside your routes.rb with your custom namespace eg. /api will result in /api/favourite_object routes

Application.routes.draw do
	mount FavouriteObject::Engine, at: '/api'
end

For every object you want to be favouritable

  • Generates a favourite_object/ObjectName/message.html.erb file which is used to display the description of an object
rails g favourite_object:template ObjectName

Favourite button(pass the object to be favourited and the user object)

<%= render :partial => 'favourite_object/favourites/favourite_icon',
	:locals => {:object => object}%>

###Api Documentation: Route: GET: /favourite_object/favourites/:target_type/:target_id.json

Example response:

{
    "favourite" => {
                      "id" => 1,
               "target_id" => 1,
             "target_type" => "ClassName",
           "is_favourited" => true,
        "third_party_flag" => false,
    }
}

Route: GET: /favourite_object/favourites.json

Optional params: {target_type: Class, target_ids: [1, 5, 10], serializer: 'lite'}

  • Note: serializer: 'lite' returns a skinny serializer which doesn't include a description and params

Example response:

{
    "favourites" => [
        {
                          "id" => 1,
                   "target_id" => 1,
                 "target_type" => "Class",
               "is_favourited" => true,
	         "description" => "Mr. Blobby",
	    "third_party_flag" => false,
	                "data" => []
        }
    ]
}

Route: PUT: /favourite_object/favourites/:target_type/:target_id.json

Params: {favourite: {is_favourited: true | false}}

Example response:

{
    "favourite" => {
                      "id" => 1,
               "target_id" => 1,
             "target_type" => "ClassName",
           "is_favourited" => true,
        "third_party_flag" => false,
    }
}

favourite_object's People

Contributors

dawilster avatar tspacek avatar rustcomet avatar

Watchers

Billy Chang avatar  avatar Mark Turner avatar James Cloos avatar John Servinis avatar Krystal Maria avatar Adam Ford avatar Jennifer Nordwall avatar Claire Taylor avatar Christian Bieniak avatar Ines Norman avatar  avatar Chris Jewell avatar  avatar  avatar  avatar Robo-Gladys avatar

favourite_object's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.