RoR programming question

Hello all,

 I am working on a sample ruby on rails application just to get an

idea on the framework. Here is where I am having a problem:

I have set up users on the site and am using acts_as_authenticated. I
set up the ability to have user A send a message to user B on the
website. I have set up a form that allows this and it is functional.
What I am trying to do now is to set up the form so that before it saves
the input into MySQL that it checks to see if the recipient user is
valid. So, what I have done is:

in my create method in my message controller, I set up an if statement
that calls the message model:

if (Usermessage.valid_recipient(@message.recipient))

Usermessage is the model, valid_recipient is the method in the model and
I am passing it a parameter of the input from the text box (recipient)
on the form.

The problem is that it does not matter what username I put into the text
box, it submits the form to the database. It doesn’t throw the second
part of the if statement which is a simple render_text “not a valid
user.” I put another render_text into the first part after the
@message.save that displays the results of
(Usermessage.valid_recipient(@message.recipient)). Doing this renders
the “#” sign to the browser.

One problem I have is I need to put some unit tests into the application
and I haven’t done this yet (I know this isn’t good, but I have to learn
about testing and doing it the right way)…

thanks for any help.
Mike

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs