head 1.8; access ; symbols ; locks ;comment @@; 1.8 date 2014.11.12.11.17.26; author p4; state Exp; branches ; next 1.6; 1.6 date 2014.11.12.10.08.58; author p4; state Exp; branches ; next 1.4; 1.4 date 2014.11.11.12.43.56; author p4; state Exp; branches ; next 1.1; 1.1 date 2014.11.11.10.18.19; author p4; state Exp; branches ; next ; desc @@ 1.8 log @@ text @class ArticlesController < ApplicationController def index if params[:sort] == "votes" @@articles = Article.order(votes_count: :desc) elsif params[:sort] == "recent" @@articles = Article.order(created_at: :desc) else @@articles = Article.all end respond_to do |format| format.html format.json { render json: @@articles } end end def show () @@message = "in view" @@article_id = params['id'] params[:id] @@article = Article.find(params[:id]) end def new @@article = Article.new end def create @@article = Article.new(article_params) flash[:success] = "Thanks for sharing" if @@article.save redirect_to article_path(@@article) else flash[:error] = "Oops, didn't quite pan out" render :new end end def edit @@article = Article.find(params[:id]) end def update @@article = Article.find(params[:id]) @@article.title = article_params[:title] @@article.body = article_params[:body] @@article.author = article_params[:author] if @@article.save flash[:success] = "Thanks for updating article titled " + @@article.to_s redirect_to article_path(@@article) else flash[:error] = "Oops, didn't quite pan out" render :edit end end private def article_params params.require(:article).permit(:title,:body,:author) end end @ 1.6 log @@ text @d5 2 d10 4 @ 1.4 log @@ text @d3 4 a6 7 t="title" b="body" @@title=[] @@body=[] 10.times do |n| @@title.append( t+n.to_s ) @@body.append(b+n.to_s) a7 1 @@articles = Article.all @ 1.1 log @@ text @d37 3 a39 1 flash[:success] = "Thanks for updating" + params.to_s d41 1 @