Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

edit view

  • Loading branch information...
commit b8ec861843067380f58e8c7bdbd2e6bd469427f4 1 parent a8c3c04
@varid007 authored
View
3  belajar/app/controllers/articles_controller.rb
@@ -7,9 +7,10 @@ def index
def create
@article = Article.new(params[:article])
if @article.save
-
+ flash[:notice] = 'Article was succesful create'
redirect_to articles_path
else
+ flash[:error] = 'Article was Error'
render :new
end
end
View
8 belajar/app/views/articles/edit.html.erb
@@ -6,17 +6,17 @@
<body>
<%= form_for @article do |f| %>
-<% if @article.errors.any? %>
- <div >
+ <% if @article.errors.any? %>
+
<h2>
<%= pluralize(@article.errors.count, "error") %> title or body was Error:
</h2>
- <ul>
+
<% @article.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
- </div>
+
<% end %>
View
1  belajar/app/views/articles/index.html.erb
@@ -4,6 +4,7 @@
</head>
<body>
+ <h3><%= flash[:notice]%></h3>
<%= link_to "Add Article",new_article_path %>
<table>
<tr>
View
10 belajar/app/views/articles/new.html.erb
@@ -4,18 +4,18 @@
</head>
<body>
- <%= form_for @article do |f| %>
- <% if @article.errors.any? %>
+ <%= form_for @article do |f| %>
+ <% if @article.errors.any? %>
<%= pluralize(@article.errors.count, "Error") %>
<% @article.errors.full_messages.each do |msg| %>
- <%= msg%>
+ <%= msg%>
<% end %>
<% end %>
Title : <br/><%= f.text_field :title %> <br/>
Article :<br/> <%= f.text_area :body %><br/>
Rating : <%= f.text_field :rating %><br/>
- <%= f.submit "Submit" %>
- <% end %>
+ <%= f.submit "Submit" %>
+ <% end %>
<%= link_to "Back to Index",articles_path%>
</body>
View
6 belajar/app/views/articles/show.html.erb
@@ -1,8 +1,8 @@
<html>
<body>
-Title : <%= @article.title %><br/>
-Body : <%= @article.body %><br/>
-Rating : <%= @article.rating %><br/>
+ Title : <%= @article.title %><br/>
+ Body : <%= @article.body %><br/>
+ Rating : <%= @article.rating %><br/>
<%= link_to "back",articles_path %>
</body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.