0

我想发出测试邀请。但是我在主页上看不到邀请表。

/static_pages/home.html.erb:(很快)

<% if signed_in? %>
  <div class="row">
    <aside class="span2">
      <section>
                <%= render 'shared/invitation_form' %>
      </section>
    </aside>
    <div class="span6 hero-unit">       
            <ol class="topics-signedin">
            <%= render 'shared/topics' %>
            </ol>
    </div>
  </div>  
<% else %>
  <div class="row">
        <div class="span10">
            <div class="center hero-unit">
                <h2>Giripedia</h2>  
                        <ol class="topics">
                        <%= render 'shared/topics' %>
                        </ol>
                <%= link_to "Üye Olun!", signup_path, 
                                class: "btn btn-large btn-primary center" %> 
        <p>Sitemiz ş....</p>

                <% form_for Invitation.new do |f| %>
                    <p>
                        <%= f.label :recipient_email, "Emailiniz:" %>
                        <%= f.text_field :recipient_email %>
                        <%= f.submit 'Gönder' %>
                    </p>
                <% end %>
            </div>
        </div>
<% end %> 

耙路线:

new_invitation GET    /invitations/new(.:format)            invitations#new
edit_invitation GET    /invitations/:id/edit(.:format)       invitations#edit
     invitation GET    /invitations/:id(.:format)            invitations#show
                PUT    /invitations/:id(.:format)            invitations#update
                DELETE /invitations/:id(.:format)            invitations#destroy

我的 static_pages_controller.rb:

  def home
        if signed_in?
        @topic = current_user.topics.build if signed_in?
        end
        @topics = Topic.paginate :page => params[:page], :per_page => 20
    @invitation = Invitation.new
  end

还有我的_invitation_form.html.erb:

<% form_for @invitation do |f| %>
  <p>
    <%= f.label :recipient_email, "Arkadaşının email adresi" %><br />
    <%= f.text_field :recipient_email %>
  </p>
  <p><%= f.submit "Davet et!" %></p>
<% end %>

日志显示:

 (0.1ms)  SELECT COUNT(*) FROM "topics" WHERE "topics"."user_id" = 1
  Rendered shared/_user_info.html.erb (2.4ms)
  Rendered shared/_error_messages.html.erb (0.4ms)
  Rendered shared/_topic_form.html.erb (2.9ms)
  Rendered shared/_invitation_form.html.erb (1.8ms)
  Topic Load (0.1ms)  SELECT "topics".* FROM "topics" ORDER BY topics.created_at DESC LIMIT 20 OFFSET 0..

但它没有显示 User.form。你知道吗?

4

1 回答 1

2

您缺少=_invitation_form.html.erb 中的一个。尝试:

<%= form_for @invitation do |f| %>
  <p>
    <%= f.label :recipient_email, "Arkadaşının email adresi" %><br />
    <%= f.text_field :recipient_email %>
  </p>
  <p><%= f.submit "Davet et!" %></p>
<% end %>

同样<% form_for ... %>在 home.html.erb 中的行

于 2012-07-02T16:31:22.133 回答