Sha256: 40c5c4422c9f632a4aa5768eef40f084602a9d64024f8dcf026b7a9310ef8133
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
require_dependency "kblog/application_controller" module Kblog class ArticlesController < ApplicationController before_filter :set_blog_user before_filter :set_article, only: [:show, :edit, :update, :destroy] if Kblog.authentication == 'basic' http_basic_authenticate_with :name => Kblog.authname, :password => Kblog.authpassword, :except => [:index,:show] end # GET /articles def index @articles = Article.order("created_at DESC").paginate(:page => params[:page], :per_page => 3) end # GET /articles/1 def show end # GET /articles/new def new @article = Article.new end # GET /articles/1/edit def edit end # POST /articles def create @article = Article.new(article_params) if @article.save redirect_to @article, notice: 'Article was successfully created.' else render action: 'new' end end # PATCH/PUT /articles/1 def update if @article.update_attributes(article_params) redirect_to @article, notice: 'Article was successfully updated.' else render action: 'edit' end end # DELETE /articles/1 def destroy @article.destroy redirect_to articles_url, notice: 'Article was successfully destroyed.' end private # Use callbacks to share common setup or constraints between actions. def set_article @article = Article.find(params[:id]) end def set_blog_user if current_user @blog_user = current_user end end # Never trust parameters from the scary internet, only allow the white list through. def article_params params[:article] #params.require(:article).permit(:title, :content) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kblog-0.0.1 | app/controllers/kblog/articles_controller.rb |