diff options
| author | Vijay Dev <vijaydev.cse@gmail.com> | 2012-04-21 23:04:04 +0530 | 
|---|---|---|
| committer | Vijay Dev <vijaydev.cse@gmail.com> | 2012-04-21 23:04:04 +0530 | 
| commit | a719843d31042690fa4fa8f55bc8a647d360b2a8 (patch) | |
| tree | d7cf910019968511bd33a15ba2c3709a366f23cd /guides/code/getting_started/app/views/posts | |
| parent | ed8108300b2bb96f9f6888188f4fb8cd418ab950 (diff) | |
| parent | c670b57f0f9ec4d992f89e62e513ff5b7baf58ac (diff) | |
| download | rails-a719843d31042690fa4fa8f55bc8a647d360b2a8.tar.gz rails-a719843d31042690fa4fa8f55bc8a647d360b2a8.tar.bz2 rails-a719843d31042690fa4fa8f55bc8a647d360b2a8.zip | |
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'guides/code/getting_started/app/views/posts')
4 files changed, 34 insertions, 69 deletions
| diff --git a/guides/code/getting_started/app/views/posts/_form.html.erb b/guides/code/getting_started/app/views/posts/_form.html.erb index e27da7f413..18cb29f335 100644 --- a/guides/code/getting_started/app/views/posts/_form.html.erb +++ b/guides/code/getting_started/app/views/posts/_form.html.erb @@ -1,32 +1,25 @@ -<% @post.tags.build %> -<%= form_for(@post) do |post_form| %> +<%= form_for :post, :url => { :action => :create } do |f| %>    <% if @post.errors.any? %> -  <div id="errorExplanation"> -    <h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2> -    <ul> -    <% @post.errors.full_messages.each do |msg| %> -      <li><%= msg %></li> -    <% end %> -    </ul> -  </div> +    <div id="errorExplanation"> +      <h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2> +      <ul> +        <% @post.errors.full_messages.each do |msg| %> +          <li><%= msg %></li> +        <% end %> +      </ul> +    </div>    <% end %> -  -  <div class="field"> -    <%= post_form.label :name %><br /> -    <%= post_form.text_field :name %> -  </div> -  <div class="field"> -    <%= post_form.label :title %><br /> -    <%= post_form.text_field :title %> -  </div> -  <div class="field"> -    <%= post_form.label :content %><br /> -    <%= post_form.text_area :content %> -  </div> -  <h2>Tags</h2> -  <%= render :partial => 'tags/form', -             :locals => {:form => post_form} %> -  <div class="actions"> -    <%= post_form.submit %> -  </div> +  <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/posts/index.html.erb b/guides/code/getting_started/app/views/posts/index.html.erb index 45dee1b25f..455a74b17f 100644 --- a/guides/code/getting_started/app/views/posts/index.html.erb +++ b/guides/code/getting_started/app/views/posts/index.html.erb @@ -1,27 +1,19 @@  <h1>Listing posts</h1> +<%= link_to 'New post', :action => :new %> +  <table>    <tr> -    <th>Name</th>      <th>Title</th> -    <th>Content</th> -    <th></th> -    <th></th> +    <th>Text</th>      <th></th>    </tr>  <% @posts.each do |post| %>    <tr> -    <td><%= post.name %></td>      <td><%= post.title %></td> -    <td><%= post.content %></td> -    <td><%= link_to 'Show', post %></td> -    <td><%= link_to 'Edit', edit_post_path(post) %></td> -    <td><%= link_to 'Destroy', post, confirm: 'Are you sure?', method: :delete %></td> +    <td><%= post.text %></td> +    <td><%= link_to 'Show', :action => :show, :id => post.id %>    </tr>  <% end %>  </table> - -<br /> - -<%= link_to 'New Post', new_post_path %> diff --git a/guides/code/getting_started/app/views/posts/new.html.erb b/guides/code/getting_started/app/views/posts/new.html.erb index 36ad7421f9..ce9523a721 100644 --- a/guides/code/getting_started/app/views/posts/new.html.erb +++ b/guides/code/getting_started/app/views/posts/new.html.erb @@ -2,4 +2,4 @@  <%= render 'form' %> -<%= link_to 'Back', posts_path %> +<%= link_to 'Back', :action => :index %> diff --git a/guides/code/getting_started/app/views/posts/show.html.erb b/guides/code/getting_started/app/views/posts/show.html.erb index da78a9527b..a79fadfe4c 100644 --- a/guides/code/getting_started/app/views/posts/show.html.erb +++ b/guides/code/getting_started/app/views/posts/show.html.erb @@ -1,31 +1,11 @@ -<p class="notice"><%= notice %></p> -   <p> -  <b>Name:</b> -  <%= @post.name %> -</p> -  -<p> -  <b>Title:</b> +  <strong>Title:</strong>    <%= @post.title %>  </p> -  -<p> -  <b>Content:</b> -  <%= @post.content %> -</p> -  +  <p> -  <b>Tags:</b> -  <%= join_tags(@post) %> +  <strong>Text:</strong> +  <%= @post.text %>  </p> -  -<h2>Comments</h2> -<%= render @post.comments %> -  -<h2>Add a comment:</h2> -<%= render "comments/form" %> -  -  -<%= link_to 'Edit Post', edit_post_path(@post) %> | -<%= link_to 'Back to Posts', posts_path %> | + +<%= link_to 'Back', :action => :index %> | 
