Про индекс блога и покажи описание и покажи все - PullRequest
0 голосов
/ 19 декабря 2009

У меня проблема с созданием блога Мне нужно что-то вроде сайта Railcast что перед вводом заголовка я увижу описание страницы индекса с ограниченной строкой после ввода названия смотрите только полный абзац я не смог сделать таким образом

My index View ::

<% for post in @posts %>
    <div class="blogPost">
        <h2>
            <%= link_to h(post.title), post %>
        </h2>
            <b>Category:</b><%=h post.category.category_name %><br/>
            <b>Posted at:</b><%=h post.date_of_creation %><br/>
            <%= "#{post.comments.count} Comments" %><br/>
        <div class="body">   
            <p><%= post.description %></p>
            <p><%=link_to "Read More...", post %></p>
        </div>
        <div class="action">
            <%= link_to "Edit", edit_post_path(post) %>
            <%= link_to "Destroy", post, :confirm => 'Are you sure?', :method => :delete %>
        </div>
    </div>

My controller ::
def index
    @posts = Post.paginate :per_page => 5, :page => params[:page], :order => 'created_at DESC'   

    respond_to do |format|
      format.html # index.html.erb
      format.js do
        render :update do |page|
          page.replace_html 'post', :partial => "post"
        end
       end
      format.xml  { render :xml => @posts }
      format.json { render :json => @posts }
      format.atom
    end
  end

и

New Post Form ::
<h1>New post</h1>

<% form_for(@post) do |f| %>
  <%= f.error_messages %>

  <p>
    <%= f.label :title %><br />
    <%= f.text_field :title %>
  </p>
  <p>
    <%= f.label :body %><br />
    <%= f.text_area :body %>
  </p>
  <p>
    <%= f.label :date_of_creation %><br />
    <%= f.date_select :date_of_creation %>
  </p>
  <p>
    <label for="category">Category<br/></label>
    <select name="category">
        <% @cat.each do |category|  %>
        <option value="<%= category.id %>">
        <%= category.category_name  %>
        </option>
        <% end %>
    </select>
  </p>
  <p>
    <%= f.submit 'Create' %>
  </p>
<% end %>

это то, что мне нужно создать новое описание вызова столбца или что я не смог позвонить с

<div class="body">   
            <p><%= post.description %></p>
            <p><%=link_to "Read More...", post %></p>
        </div>

Парень, есть идеи получше? Спасибо за ответ ~

1 Ответ

0 голосов
/ 20 декабря 2009

Я нашел решение, которое заключалось в использовании метода усечения.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...