[Rails] Re: Best way to do a find_by_or_create based on an attribute?

2010-12-15 Thread Marnen Laibow-Koser
Aston J. wrote in post #968740: I have a form for @topic that contains two fields, name(string) visible(boolean) When the user submits the form, I want to manipulate the contents of the attribute :name (which I am able to do - but it's the next part I'm stuck on) -and then- see if a

[Rails] Re: Best way to do a find_by_or_create based on an attribute?

2010-12-15 Thread Aston J.
Thanks for the reply both. Does this make it any clearer? It is my create action based on what Philip said - but it does not work: Topic(#2171041280) expected, got Hash(#2151972860) def hashtag(name) string = name return name = string if string.split.count = 1 name =

Re: [Rails] Re: Best way to do a find_by_or_create based on an attribute?

2010-12-15 Thread Philip Hallstrom
Thanks for the reply both. Does this make it any clearer? It is my create action based on what Philip said - but it does not work: Topic(#2171041280) expected, got Hash(#2151972860) You're trying to add a hash to an AR association... Rails doesn't like that :) def hashtag(name)