On Tue, Feb 16, 2010 at 12:17 AM, Greg Ma <gregorylepacha / msn.com> wrote:

> No i cannot do this because the parameter isnt a tag object but just a
> string.
> I guess i could try this
> def find_students_by_tag(tag)
>   res = Tag.find_by_name(tag)
>  res.students unless res
> end
> --
> Posted via http://www.ruby-forum.com/.
>
>
Have you looked at the acts_as_taggable plugin?
http://juixe.com/techknow/index.php/2006/07/05/acts-as-taggable-plugin/

That page has an example posts = Post.find_tagged_with('tag1')

Which looks like you should be able to say

Student.find_tagged_with(tag)

Rather than the method you are currently trying to create
Student.find_students_by_tag(tag)

(actually, if you were wanting to call it like that, then it should be
defined "def self.find_students_by_tag" because it should be a method on the
Student class rather than on some particular student)