This commit is contained in:
parent
cd73e4810a
commit
3452a81971
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
<th><%= model_class.human_attribute_name(:rate) %></th>
|
||||
<th><%= model_class.human_attribute_name(:active) %></th>
|
||||
<th><%= model_class.human_attribute_name(:created_by) %></th>
|
||||
<th><%= model_class.human_attribute_name(:updated_by) %></th>
|
||||
<th><%= model_class.human_attribute_name(:created_at) %></th>
|
||||
<th><%=t '.actions', :default => t("helpers.actions") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
@ -24,9 +22,7 @@
|
|||
<td><%= article.content %></td>
|
||||
<td><%= article.rate %></td>
|
||||
<td><%= article.active %></td>
|
||||
<td><%= article.created_by %></td>
|
||||
<td><%= article.updated_by %></td>
|
||||
<td><%=l article.created_at %></td>
|
||||
<td><%= article.created %></td>
|
||||
<td>
|
||||
<%= link_to t('.edit', :default => t("helpers.links.edit")),
|
||||
edit_article_path(article), :class => 'btn btn-default btn-xs' %>
|
||||
|
|
|
|||
Loading…
Reference in New Issue