diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-26 17:26:27 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-26 17:26:27 -0300 |
commit | 772c57182dcd6fb1d223369f1531ef48813cdac0 (patch) | |
tree | 7727e64c94b8669596d3f0e464ad33322fc31866 /guides/code/getting_started/app/views/articles | |
parent | 49f03a77ed3ed286daeb440603ac799037b66c33 (diff) | |
parent | 45072f34d27bda34b182f14f8b02d778d1648cce (diff) | |
download | rails-772c57182dcd6fb1d223369f1531ef48813cdac0.tar.gz rails-772c57182dcd6fb1d223369f1531ef48813cdac0.tar.bz2 rails-772c57182dcd6fb1d223369f1531ef48813cdac0.zip |
Merge pull request #15323 from JohnKellyFerguson/getting-started-app
Docs: Rename Posts to Articles in Guides' Getting Started App
Diffstat (limited to 'guides/code/getting_started/app/views/articles')
5 files changed, 76 insertions, 0 deletions
diff --git a/guides/code/getting_started/app/views/articles/_form.html.erb b/guides/code/getting_started/app/views/articles/_form.html.erb new file mode 100644 index 0000000000..87e3353ed2 --- /dev/null +++ b/guides/code/getting_started/app/views/articles/_form.html.erb @@ -0,0 +1,27 @@ +<%= form_for @article do |f| %> + <% if @article.errors.any? %> + <div id="error_explanation"> + <h2><%= pluralize(@article.errors.count, "error") %> prohibited + this article from being saved:</h2> + <ul> + <% @article.errors.full_messages.each do |msg| %> + <li><%= msg %></li> + <% end %> + </ul> + </div> + <% end %> + <p> + <%= f.label :title %><br> + <%= f.text_field :title %> + </p> + + <p> + <%= f.label :text %><br> + <%= f.text_area :text %> + </p> + + <p> + <%= f.submit %> + </p> +<% end %> + diff --git a/guides/code/getting_started/app/views/articles/edit.html.erb b/guides/code/getting_started/app/views/articles/edit.html.erb new file mode 100644 index 0000000000..14236e2a98 --- /dev/null +++ b/guides/code/getting_started/app/views/articles/edit.html.erb @@ -0,0 +1,5 @@ +<h1>Edit article</h1> + +<%= render 'form' %> + +<%= link_to 'Back', action: :index %> diff --git a/guides/code/getting_started/app/views/articles/index.html.erb b/guides/code/getting_started/app/views/articles/index.html.erb new file mode 100644 index 0000000000..80e9c8c60c --- /dev/null +++ b/guides/code/getting_started/app/views/articles/index.html.erb @@ -0,0 +1,21 @@ +<h1>Listing Articles</h1> +<table> + <tr> + <th>Title</th> + <th>Text</th> + <th></th> + <th></th> + <th></th> + </tr> + +<% @articles.each do |article| %> + <tr> + <td><%= article.title %></td> + <td><%= article.text %></td> + <td><%= link_to 'Show', action: :show, id: article.id %></td> + <td><%= link_to 'Edit', action: :edit, id: article.id %></td> + <td><%= link_to 'Destroy', { action: :destroy, id: article.id }, + method: :delete, data: { confirm: 'Are you sure?' } %></td> + </tr> +<% end %> +</table> diff --git a/guides/code/getting_started/app/views/articles/new.html.erb b/guides/code/getting_started/app/views/articles/new.html.erb new file mode 100644 index 0000000000..652b1c9c0b --- /dev/null +++ b/guides/code/getting_started/app/views/articles/new.html.erb @@ -0,0 +1,5 @@ +<h1>New article</h1> + +<%= render 'form' %> + +<%= link_to 'Back', action: :index %> diff --git a/guides/code/getting_started/app/views/articles/show.html.erb b/guides/code/getting_started/app/views/articles/show.html.erb new file mode 100644 index 0000000000..6959c80bdb --- /dev/null +++ b/guides/code/getting_started/app/views/articles/show.html.erb @@ -0,0 +1,18 @@ +<p> + <strong>Title:</strong> + <%= @article.title %> +</p> + +<p> + <strong>Text:</strong> + <%= @article.text %> +</p> + +<h2>Comments</h2> +<%= render @article.comments %> + +<h2>Add a comment:</h2> +<%= render "comments/form" %> + +<%= link_to 'Edit Article', edit_article_path(@article) %> | +<%= link_to 'Back to Articles', articles_path %> |