0

我在 Rails 4 中实现 Mailboxer gem 的视图时遇到困难。到目前为止,我已经设置了用户可以向其他用户发送消息的位置,但我无论如何都没有让用户看到他们的对话。

即使在我创建了部分视图之后,我也收到了这个错误:(尝试从示例应用程序中复制视图)

ActionView::Template::Error (Missing partial mailboxer/conversations/_conversation with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in:

所以我最终只是删除了视图。这是我发送消息时发生的情况:

2.1.1 :004 > User.first.send_message(User.last, "body", "subject")
  User Load (0.3ms)  SELECT  "users".* FROM "users"   ORDER BY "users"."id" ASC LIMIT 1
  User Load (0.2ms)  SELECT  "users".* FROM "users"   ORDER BY "users"."id" DESC LIMIT 1
   (0.1ms)  begin transaction
  SQL (0.4ms)  INSERT INTO "mailboxer_conversations" ("created_at", "subject", "updated_at") VALUES (?, ?, ?)  [["created_at", "2014-06-24 17:51:36.131962"], ["subject", "subject"], ["updated_at", "2014-06-24 17:51:36.131962"]]
  SQL (0.2ms)  INSERT INTO "mailboxer_notifications" ("body", "conversation_id", "created_at", "sender_id", "sender_type", "subject", "type", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?)  [["body", "body"], ["conversation_id", 3], ["created_at", "2014-06-24 17:51:36.131962"], ["sender_id", 1], ["sender_type", "User"], ["subject", "subject"], ["type", "Mailboxer::Message"], ["updated_at", "2014-06-24 17:51:36.131962"]]
  SQL (0.2ms)  INSERT INTO "mailboxer_receipts" ("created_at", "mailbox_type", "notification_id", "receiver_id", "receiver_type", "updated_at") VALUES (?, ?, ?, ?, ?, ?)  [["created_at", "2014-06-24 17:51:36.222349"], ["mailbox_type", "inbox"], ["notification_id", 3], ["receiver_id", 5], ["receiver_type", "User"], ["updated_at", "2014-06-24 17:51:36.222349"]]
   (2.9ms)  commit transaction
   (0.1ms)  begin transaction
  SQL (0.8ms)  INSERT INTO "mailboxer_receipts" ("created_at", "is_read", "mailbox_type", "notification_id", "receiver_id", "receiver_type", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?)  [["created_at", "2014-06-24 17:51:36.229168"], ["is_read", "t"], ["mailbox_type", "sentbox"], ["notification_id", 3], ["receiver_id", 1], ["receiver_type", "User"], ["updated_at", "2014-06-24 17:51:36.229168"]]
   (0.9ms)  commit transaction
   (0.3ms)  SELECT COUNT(*) FROM "mailboxer_conversation_opt_outs"  WHERE "mailboxer_conversation_opt_outs"."conversation_id" = ? AND "mailboxer_conversation_opt_outs"."unsubscriber_type" = 'User' AND "mailboxer_conversation_opt_outs"."unsubscriber_id" = 5  [["conversation_id", 3]]
   (0.4ms)  SELECT COUNT(*) FROM "mailboxer_notifications"  WHERE "mailboxer_notifications"."type" IN ('Mailboxer::Message') AND "mailboxer_notifications"."conversation_id" = ?  [["conversation_id", 3]]



 => #<Mailboxer::Receipt id: 6, receiver_id: 1, receiver_type: "User", notification_id: 3, is_read: true, trashed: false, deleted: false, mailbox_type: "sentbox", created_at: "2014-06-24 17:51:36", updated_at: "2014-06-24 17:51:36"> 
4

1 回答 1

0

我遇到了同样的问题,我与制作示例应用程序并更新到 4.1 的人交谈。你可以用它来指导你。

我这样使用它:

控制器

def index
        @inbox ||= current_user.mailbox.inbox
end 

看法

<% @inbox.each do |conversation| %>
    <%= conversation.originator.username%>
    <%= link_to  raw(truncate(strip_tags(conversation.subject), :length => 15)), conversation_path(conversation) %> 
        <%= link_to "", {:controller => "conversations", :action => "trash", :id => conversation.id}, :title=> "Move to Trash", :method=>'post', data: { confirm: '¿Estas seguro?' }, :class=> "btn btn btn-danger icon-remove" %>
     <%= conversation.updated_at%>
<% end %>

这是一个想法,所以你可以开始。

于 2014-07-14T09:35:54.360 回答