I’ve been setting up a user to user messaging system using this rails tutorial http://www.novawave.net/public/rails_messaging_tutorial.html
I know its pretty old but I haven’t really had a problem tweaking it to work now. My only problem is that the inbox is not displaying and the error that appears is “Couldn’t find Folder without an ID” I’m not sure what I should do. My code is pretty much the same, besides some tweaks, with the code in that link until right before reply. Thats where I stopped.
My Folder Model looks like
class Folder < ActiveRecord::Base
acts_as_tree
belongs_to :user
has_many :messages, :class_name => "MessageCopy"
end
My Mailbox controller looks like
class MailboxController < ApplicationController
def index
redirect_to new_session_path and return unless signed_in?
@folder = current_user.inbox
show
render :action => "show"
end
def show
@folder ||= current_user.folders.find(params[:id])
@messages = @folder.messages.paginate :per_page => 10, :page => params[:page], :include => :message, :order => "messages.created_at DESC"
end
end
If any other code needs to be included let me know.
It looks like when you call
showfrom within the index action that @folder is not set and so it callscurrent_user.folders.find(params[:id])but because of the way you have called itparams[:id]is nil.This would cause an exception.
I suggest instead to change your index action to look like this:
Instead of rendering the show action from within the index action, just redirect to the show method with the correct id parameter.