From 3452a81971590bfce5f680b300c4352d4631dd8a Mon Sep 17 00:00:00 2001 From: ahinz Date: Thu, 11 Dec 2014 15:45:49 +0100 Subject: [PATCH] ` --- app/controllers/articles_controller.rb | 19 ++++++++++--------- app/models/article.rb | 7 +------ app/views/articles/index.html.erb | 6 +----- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index 369550e..0029a91 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -26,7 +26,8 @@ class ArticlesController < ApplicationController # POST /articles.json def create @article = Article.new(article_params) - + @article.created_by = current_user.id + @article.updated_by = current_user.id respond_to do |format| if @article.save format.html { redirect_to @article, notice: 'Article was successfully created.' } @@ -63,13 +64,13 @@ class ArticlesController < ApplicationController end private - # Use callbacks to share common setup or constraints between actions. - def set_article - @article = Article.find(params[:id]) - end + # Use callbacks to share common setup or constraints between actions. + def set_article + @article = Article.find(params[:id]) + end - # Never trust parameters from the scary internet, only allow the white list through. - def article_params - params.require(:article).permit(:title, :content, :rate, :active, :created_by, :updated_by) - end + # Never trust parameters from the scary internet, only allow the white list through. + def article_params + params.require(:article).permit(:title, :content, :rate, :active, :created_by, :updated_by) + end end diff --git a/app/models/article.rb b/app/models/article.rb index 79e555a..c5b93e7 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -5,14 +5,9 @@ class Article < ActiveRecord::Base before_destroy :b_destroy def b_create - self.created_by = current_user.id - self.updated_by = current_user.id + self.rate = 0.0 end - def b_update - self.updated_by = current_user.id - end - def b_destroy #ToDo destroy comments end diff --git a/app/views/articles/index.html.erb b/app/views/articles/index.html.erb index 0e29c60..2be8bda 100644 --- a/app/views/articles/index.html.erb +++ b/app/views/articles/index.html.erb @@ -11,8 +11,6 @@ <%= model_class.human_attribute_name(:rate) %> <%= model_class.human_attribute_name(:active) %> <%= model_class.human_attribute_name(:created_by) %> - <%= model_class.human_attribute_name(:updated_by) %> - <%= model_class.human_attribute_name(:created_at) %> <%=t '.actions', :default => t("helpers.actions") %> @@ -24,9 +22,7 @@ <%= article.content %> <%= article.rate %> <%= article.active %> - <%= article.created_by %> - <%= article.updated_by %> - <%=l article.created_at %> + <%= article.created %> <%= link_to t('.edit', :default => t("helpers.links.edit")), edit_article_path(article), :class => 'btn btn-default btn-xs' %>