Last active
May 23, 2016 00:54
-
-
Save lucasmarqs/252929871df1629e733332a044e32650 to your computer and use it in GitHub Desktop.
Minimum CRUD on Rails
This file contains 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 Admin::ToolsController < AdminController | |
expose :tools, ancestor: :company | |
expose :tool, attributes: :tool_params | |
def create | |
if tool.save | |
set_flash_success_and_redirect_to admin_tools_path | |
else | |
render :new | |
end | |
end | |
def update | |
if tool.save | |
set_flash_success_and_redirect_to admin_tools_path | |
else | |
render :edit | |
end | |
end | |
def destroy | |
if tool.destroy | |
set_flash_success_and_redirect_to admin_tools_path | |
else | |
set_flash_error_and_redirect_to admin_tools_path | |
end | |
end | |
private | |
def tool_params | |
params.require(:tool).permit(:name) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment