-1

Update

The error was that rails cant find the root_url

Visit <%= link_to root_url, root_url %> and go to your inbox for more info.

for a quick fix and I dont need to sent the user to the root_url just a notification for the user to go to the app. I change the code to this: on the mailbox email views

Visit **messages** and go to your inbox for more info.

Question

I got devise set with my rails 4 app. Im following the example mailboxer-app when I sent the message I get a error:

`error undefined local variable or method `root_url' for #<#<Class:0x007ffe0b881678>:0x007ffe0b068298>`

Stuff I have fix to get it working

  • Got the form sending message to user with email
  • user can sent and reply
  • mark as delete
  • view inbox,sentbox and trash

this are my steps

  • install gem -v 0.12.1
  • rails g mailboxer:install
  • run migration
  • use the code from the example app(controller,view,routes)
  • add to my user.rb acts_as_messageable and

Conversations Controller

  before_filter :authenticate_user!
  helper_method :mailbox, :conversation

  def index
        @inbox ||= current_user.mailbox.inbox.paginate(:page => params[:inbox], :per_page => 5  )
        @sentbox ||= current_user.mailbox.sentbox.paginate(:page => params[:sentbox], :per_page => 5    )
        @trash ||= current_user.mailbox.trash.paginate(:page => params[:trash], :per_page => 5  )
  end
  def create
    recipient_emails = conversation_params(:recipients).split(',')
    recipients = User.where(email: recipient_emails).all

     conversation = current_user.
      send_message(recipients, *conversation_params(:body, :subject)).conversation

    redirect_to :conversations
  end

form

<%= bootstrap_form_for :conversation, url: :conversations do |f| %>
    <%= f.text_field :recipients%>
    <%= f.text_field :subject%>
    <%= f.text_field :body %>
    <div class="form-actions">
      <%= f.primary "send" %>
      <%= submit_tag 'Cancel', type: :reset, class: 'btn btn-danger' %>
    </div>
  <% end %>

View

<% @inbox.each do |conversation| %>
<%= conversation.originator.username%>
<%= link_to  raw(truncate(strip_tags(conversation.subject), :length => 15)), conversation_path(conversation) %>
 <% end %>
Frank004
  • 228
  • 1
  • 2
  • 16
  • Find tutorial in Google. What is the problem of current codes above? – Raptor Jun 20 '14 at 02:50
  • I have look for 1 week and nothing that can help me. The part that i need help its setup the basic views to work with mailboxer. after that I can work my self on the rest I got this code form the tut. and working my way but having a hardtimes with the views – Frank004 Jun 20 '14 at 03:26
  • you still didn't mention what error did you encounter – Raptor Jun 20 '14 at 03:31
  • I was look for any basic guide for setup rails 4. the problem that Im getting is the tutorials and guides that I found are old version and not working. But ill try posting what I got on my views and controllers – Frank004 Jun 20 '14 at 03:44
  • I change my Question and info see now its better thank you for your time. – Frank004 Jun 20 '14 at 05:52
  • I try just the simple stuff and still get this error ActionView::MissingTemplate - Missing partial mailboxer/conversations/_conversation with this simple code <%= render current_user.mailbox.inbox %> – Frank004 Jun 21 '14 at 03:08
  • @Raptor I re-write the post and found a answer to my question I like is you can check my negative post point on this post. thank you I learning to use this places put I think is to sever with newcomers. – Frank004 Jun 23 '14 at 00:45

1 Answers1

1

Ok got the fix to this problem. what happen is that the mailboxer mailer was looking for root_url. Rails 4.1 wont generate the views for that just copy the files from the source code and works greate.

and just change that part of the code here.

view/mailboxer/all of this files message_mailer notification_mailer

change this

Visit <%= link_to root_url, root_url %> and go to your inbox for more info.

to this

Visit **messages** and go to your inbox for more info.

Thanx to this guy supremebeing7. on the mailboxer issue page

Frank004
  • 228
  • 1
  • 2
  • 16