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 に答える