you use conditions
:conditions =>
checkout
http://rubyonrails.org/api/classes/ActiveRecord/Base.html
On 8/1/06, Bob <test@example.com> wrote:>
>
> I''ve created the following function, and for testing have
hardcoded the
> following values:
>
> def addNewRow
> @timesheet = Timesheet.find(:employee_id => ''1'',
> :cost_code_id =>
''14'',
> :dept => ''007'',
> :ending_date =>
''2006-07-15'')
> if @timesheet == nil
> Timesheet.create(:employee_id => ''1'',
> :cost_code_id => ''14'',
> :dept => ''007'',
> :ending_date => ''2006-07-15'')
> end
> redirect_to_index()
> end
>
> The create code does work, but I am trying to add the find to avoid
> duplicates. What is the format to mimic the where clause of a query?
>
> Thanks!
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060801/3385926c/attachment.html