Sha256: d6665487daaffcb6e4561a288710a74eb6820279c0f201543fe95f98ce9fc287
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
class TopicsController < ApplicationController before_action :set_topic, only: [:show, :edit, :update, :destroy] def index @topics = Topic.all end def show end def new @topic = Topic.new end def edit end def create @topic = Topic.new(topic_params) respond_to do |format| if @topic.save format.html { redirect_to @topic, notice: 'Topic was successfully created.' } format.json { render :show, status: :created, location: @topic } else format.html { render :new } format.json { render json: @topic.errors, status: :unprocessable_entity } end end end def update respond_to do |format| if @topic.update(topic_params) format.html { redirect_to @topic, notice: 'Topic was successfully updated.' } format.json { render :show, status: :ok, location: @topic } else format.html { render :edit } format.json { render json: @topic.errors, status: :unprocessable_entity } end end end def destroy @topic.destroy respond_to do |format| format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' } format.json { head :no_content } end end private def set_topic @topic = Topic.find_by_slug(params[:id]) end def topic_params params.require(:topic).permit(:title, :slug, :color, :views) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
friendly_slug-0.1.6 | friendly_slug_gem_test/app/controllers/topics_controller.rb |