0.0
No commit activity in last 3 years
No release in over 3 years
Create, Update and Delete all in one line.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
 Project Readme

simple_crud

Gem Version

Clean up those controllers with some simple CRUD!

Download

Github: https://github.com/Jordan-deJong/simple_crud.git

Gem: gem install simple_crud

Installation

Load the gem in the appropriate environments using Rails' 3.2+ gem support.

gem "simple_crud"

Configuration

  class ApplicationController < ActionController::Base
    # Prevent CSRF attacks by raising an exception.
    # For APIs, you may want to use :null_session instead.
    before_action :confirm_logged_in

    protect_from_forgery with: :exception

    private

    include SimpleCrud

  end

Implementation

  def create
    @user = User.new(user_params) # Create a new class
    @user.company_id = session[:company_id] # Add any other attributes
    create_ @user, users_path, :new # Save the instance, Redirect_to if save successful, #render template if not successful
  end

  def update
    update_ @user, user_params, users_path # Update the instance, Redirect_to if successful, # Always renders edit
  end

  def destroy
    destroy_ @user, users_path # Delete instance, Redirect_to after delete
  end

Version

0.0.2

Copyright

Copyright (c) 2015 Jordan de Jong, jordandejong.com.

This project rocks and uses MIT-LICENSE.