Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Admin::ForumsController < ApplicationController
- layout "admin"
- before_action :find_forum, only: [:edit, :update, :destroy]
- def index
- @forums = Fora.all
- render :template => "admin/forums/index"
- end
- def new
- @forum = Fora.new
- render :template => "admin/forums/new"
- end
- def create
- @forum = Fora.new(forum_params)
- if @forum.save
- redirect_to admin_forums_path, notice: "Forum crée avec succés."
- else
- render 'new'
- end
- end
- def edit
- end
- def update
- if @forum.update(forum_params)
- redirect_to admin_forums_path, notice: "Forum modifié avec succés."
- else
- render 'edit'
- end
- end
- def destroy
- @forum.destroy
- redirect_to admin_forums_path, notice: "Forum supprimé avec succés."
- end
- private
- def find_forum
- @forum = Fora.find(params[:id])
- end
- def forum_params
- params.require(:forum).permit(:title, :content)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement