Displaying 3 results from an estimated 3 matches for "find_or_create_by_part_number".
2006 Mar 14
1
Dynamic Finders with _or_create Don''t Work?
What could cause this?
>> sdfl=PartNumber.find_by_part_number("1111111")
=> #<PartNumber:0xb78fc744 @attributes={"id"=>"11601",
"part_number"=>"1111111"}>
>> sdfl=PartNumber.find_or_create_by_part_number("1111111")
NoMethodError: undefined method `find_or_create_by_part_number'' for
PartNumber:Class
from /usr/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/base.rb:942:in
`method_missing''
from (irb):5
I could swear this used to work.
- Ian
2006 Jan 11
0
Easy Question, I Think
...art_name])
# The find portion of this seems to try to find the record,
regardless of whether
# the input is of the wrong type. I suppose that makes sense, but
there must
# be an easier way than explicitly calling .valid?
if @part_number.valid?
@part.part_number =
PartNumber.find_or_create_by_part_number(params[:part_number][:part_number])
end
if @part.save
flash[:notice] = ''Part was successfully created.''
redirect_to :action => ''list''
else
render :action => ''new''
end
end
def edit
@part = Part.fi...
2006 Jan 12
0
Easy Question, I Think [re-post, sorry if dupe]
...art_name])
# The find portion of this seems to try to find the record,
regardless of whether
# the input is of the wrong type. I suppose that makes sense, but
there must
# be an easier way than explicitly calling .valid?
if @part_number.valid?
@part.part_number =
PartNumber.find_or_create_by_part_number(params[:part_number][:part_number])
end
if @part.save
flash[:notice] = ''Part was successfully created.''
redirect_to :action => ''list''
else
render :action => ''new''
end
end
def edit
@part = Part.fi...