I’m trying to create an web app where users can write messages to each other. I use the restful_authentication plugin for the users. So they have an user_id. How ever the messages should have a:
As i saw in some screencast the association use the user_id to connect users to something. But in my model there would be 2 user_id column which obviously doesn’t work. So how do I do it?
My workaround was to create a receiver and sender model which contained a user_id and a message_id. Then the message contained a sender_id, receiver_id and the content. However now I’m stuck somehow. Maybe it’s because 2:30am here and I should be in bed. I don’t know. Is there an easier workaround? Some tutorials, maybe?
How do I collect my mails? Have a controller named messages where I tried this, but it doesn’t work (I thing my association declaration are the cause):
@inbox = current_user.message.find_by_receiver_id(:user)
class Message < ActiveRecord::Base
validates_length_of :content, :maximum => 4096
class Receiver < ActiveRecord::Base
class Sender < ActiveRecord::Base
class User < ActiveRecord::Base (restful_authentication plugin)
Virtual attribute for the unencrypted passwordattr_accessor :password
attr_accessible :login, :email, :password, :password_confirmation
Greetings and thanks for any kind of help