views:

133

answers:

3

I am building an application and it needs to have a feature whereby one user can send another user a message. The system can be the most basic type available in rails and that would suit me fine.

Any ideas on how to go about this?

Thanks.

+1  A: 

Table structure like this:

Users
name,pwd

Messages
title,body

UserMessages
user_id,message_id
huacnlee
+1  A: 

Why don't you use acts_as_messageable plugin:http://www.philsergi.com/2007/10/actsasmessageable-plugin-released_04.html ?

Similarly, there are other plug-ins for authentication (restful authentication).

uzurpatorul
A: 

So i have implemented the DB tables and now need to pass the data around my system which im finding quite troubling. When the user clicks "send message to" on my form i need it to carry the id of the profile which the user is viewing. I thought this would do that:

<%= link_to "Message", :action => 'message', :id => @user.id %>

Now this pass the persons ID who i was looking to the message action (i know @user.id should work because i use @user.detail to view other details about the user on that page)

My controller should then receive that @user.id, heres my controller:

def message
 @reciever = User.find_by_id(params[:id])
end

and in my view for i want to show the recievers id so i thought that

<label>Send Message To: <%= render :text => @reciever.id %></label>

would be suffiencent.

Any ideas?

what part of this is failing?
Maximiliano Guzman