[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)

[Rails] Re: Best way to do testing / load seed data?

2010-12-08 Thread daze
Hey thanks! Just like to say that factory_girl_rails (factory_girl for Rails 3) works excellently. On Dec 6, 5:24 pm, Marnen Laibow-Koser li...@ruby-forum.com wrote: daze wrote in post #966672: What is the preferred way to have testing data - fixtures, or something like factory_girl

[Rails] Re: Best way to do testing / load seed data?

2010-12-06 Thread Marnen Laibow-Koser
daze wrote in post #966672: What is the preferred way to have testing data - fixtures, or something like factory_girl (https://github.com/thoughtbot/ factory_girl)? Factories. Never use fixtures, ever, for anything. I definitely need something that can handle relationships between things

Re: [Rails] Re: Best way to do this

2010-01-30 Thread Jamey Cribbs
On Fri, Jan 29, 2010 at 10:52 PM, Steve Castaneda li...@ruby-forum.com wrote: Jamey Cribbs wrote: Sounds like you do not have your associations defined correctly in your model. In your Buyer model you should have this line:     belongs_to :status In your Status model you should have this

[Rails] Re: Best way to do this

2010-01-30 Thread Marnen Laibow-Koser
Steve Castaneda wrote: Jamey Cribbs wrote: Sounds like you do not have your associations defined correctly in your model. In your Buyer model you should have this line: belongs_to :status In your Status model you should have this line: has_many :buyers HTH, Jamey

[Rails] Re: Best way to do this

2010-01-29 Thread Steve Castaneda
I'm beginning to think there needs to be a third table; one whose columns are: id, buyer_id, status_id This would be my first time doing it like this though, so I sort of get stuck understanding how the route is supposed to work. -- Posted via http://www.ruby-forum.com/. -- You received

[Rails] Re: Best way to do this

2010-01-29 Thread Steve Castaneda
Jamey Cribbs wrote: Sounds like you do not have your associations defined correctly in your model. In your Buyer model you should have this line: belongs_to :status In your Status model you should have this line: has_many :buyers HTH, Jamey That was it! Thank you

[Rails] Re: Best way to do filtering/refinements?

2009-06-05 Thread Sandip Ransing
Do you mean there are products of different types ( models ) quite confused ?? On Fri, Jun 5, 2009 at 9:33 PM, Yanni Mac rails-mailing-l...@andreas-s.netwrote: I have a Store model that has_many Products. I need to allow the users to filter on certain conditions in the products. For

[Rails] Re: Best way to do filtering/refinements?

2009-06-05 Thread Yanni Mac
There are not different models for products. Product is one model and it has fields for price, etc.. I want to filter out products based on price: :conditions=price50 Sandip Ransing wrote: Do you mean there are products of different types ( models ) quite confused ?? On Fri, Jun 5,

[Rails] Re: Best way to do filtering/refinements?

2009-06-05 Thread Matt Jones
You're probably looking for named scopes. They can be used to add conditions to an association, like store.products, on the fly. For instance, if you have these named scopes on your Product model: named_scope :price_less_than, lambda { |p| { :conditions = ['price = ?', p] } } named_scope