similar to: Validation question

Displaying 20 results from an estimated 10000 matches similar to: "Validation question"

2006 Mar 15
3
Self-referential join model does not work
I have been trying to model a labeled graph using ActiveRecord (trunk version). Basically, I have a ''Node'' model which represents a node linking to other nodes. Links (aka edges) are labeled (i.e., have a ''label'' attribute and other behavior). Thus I decided to model edges as an ''Edge'' model and use a ''has_many :trough''
2006 Mar 20
2
AHHHhhhhh... has_and_belongs_to_many, that is going on?
I don''t have a class by the name of "ReviewersScoreCard", yet my many to many configuration looks as follows. And, these errors while running some simple test with ./script/console is giving me a headache: ./script/console Loading development environment. >> r = Reviewer.find_first => #<Reviewer:0x19d0a48 @attributes={"id"=>"1",
2006 Feb 27
4
2 belongs_to to the same parent table
Hello! I have 2 table: users and buddies User: id, name, ... Buddy: id, user_id, user_buddy_id, ... So if you have 2 users 1,jack and 2,fred and fred is a buddy of jack, there is a Buddy object: id=1, user_id=1, user_buddy_id=2 I can declare only one belongs_to in Buddy and one has_many in User. And there is conflict if I had the second one (the first one is discarded) class User has_many
2005 Dec 15
8
How to ensure deletes cascade to associated models?
I have the following models: class Resume belongs_to :resume_assignments end class User belongs_to :resume_assignments end class ResumeAssignment has_one :resume has_one :user end When I delete a resume, I want to make sure that its associated ResumeAssignment gets deleted also. Calling destroy_all to delete some resumes doesn''t seem to do this. Is there an option that will
2008 Jul 17
5
.build method
I have gone to the api and have searched the internet and looked through the books that I have, but I am having trouble finding an explanation on what the .build method actually does and how it is used. I guess the best example is if I want to create a todo list application where I can create a new todo list and add to do items all at the same time. I would post to the todolist controller to
2006 Jan 29
16
counting rows via associations
Hi: I have a table called clients and each client has many lists (a has_many and belongs_to has been created in the class. What I need to do is get a count of the rows in each list for each client. I was hoping I could do something like client.lists.count but it does not seem to work. Any suggestions? bruce
2007 Feb 04
2
Per activerecord object callbacks (aka: should I have gone to bed hours ago?)
First of all, I should have gone to bed a long time, so please be forgiving with regards to what will follow :) So I''ve been working all day on a rails project that needs to go out soon, and I thought I would try to refactor a has_many relationship to a has_and_belongs_to_many relationship (using has_many :through). However, I then realized that I would loose a lot of the simple beauty
2005 Nov 23
15
:conditions => ... formatting
With code like: if @params[:pnumber] =~ /\s*p?(\d+)\s*/ if student = Student.find_first(:conditions => ["pnumber like \":pnumber%\"", {:pnumber => $1}]) @borrower = student elsif emp = Employee.find_first(:condiwions => ["pnumber like \"?\"", {:pnumber => $1}]) @borrower = emp else
2008 Mar 04
6
find_all_by deprecated?
Is find_all_by deprecated and/or find_first_by for 2.0.2? If not, what is actually deprecated? just find_all(..) and find_first()? Thanks for clearing this up. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to
2006 Mar 02
5
Deparsing '...'
Hi, The following function works, but is there a neater way to write it? f = function(x,...) { # return a character vector of the arguments passed in after 'x' gsub(" ","",unlist(strsplit(deparse(substitute(list(...))),"[(,)]")))[-1] } > f(x,a,b,c*d) [1] "a" "b" "c*d" > Thanks. [[alternative HTML
2007 Dec 10
5
Neat conditional assignment
I would like to make a new vector with values taken from two existing vectors conditional upon a third. At present I am doing this with a for loop but wonder if there is not a neater way, given some of the very neat things R can do. a<-rep(c("A","B"),50) b<-rep(1,100) c<-rep(2,100) a is thus "A" "B" "A" "B" "A"
2016 Mar 20
2
ssh-copy-id no newline bug
On Sun, Mar 20, 2016 at 03:51:23PM -0400, Stephen Harris wrote: > On Sun, Mar 20, 2016 at 07:30:01PM +0000, Alex Bligh wrote: > > On 20 Mar 2016, at 19:15, Philip Hands <phil at hands.com> wrote: > > > Is anyone going to be upset by the resulting blank lines being added by > > > ssh-copy-id when the file was not missing a terminating newline? > > > >
2006 Jan 12
1
A really newbie question
Hi, I have been playing around with Ruby after reading so much about it, and so I started tweaking with auto generated scaffold. But it seems like I must be missing something, can someone else please help me take a look and give me a couple pointers? In short I was trying to make a class User that has a method addupdate with 2 parameters (alias and email) which would either update the
2005 Jul 23
11
Validation without ActiveRecord
Hello, I followed the instructions at http://wiki.rubyonrails.com/rails/show/HowToUseValidationsWithoutExtendingActiveRecord But now I''m having trouble trying to create my form view. Here''s a brief rundown of what I''ve done: - Created a class called SearchRequest that extends ValidatingBase and saved it in a file called search_request.rb and put it in my models
2006 Mar 24
6
Should counter_cache fields be saved in the database?
As far as I can tell, the counter_cache option on a belongs_to model doesn''t actually save anything in the database. For example, I have the following models: class Parent < ActiveRecord::Base has_many :children, :conditions => "deleted_at IS NULL" end class Child < ActiveRecord::Base belongs_to :parent, :counter_cache => true end With the following
2006 May 03
2
Conditional statement style
This is a bit of a nuby question methinks but i''ve had a play/search around and it''s just bugging me now :0) Say I have a conditional statement, testing a variable against a number of values. The first way i did this is like so: if myvar != "" and myvar != 0 and myvar != nil # .. code end This seems a bit messy - is there neater way of doing this? I thought of:
2020 Apr 16
2
suggestion: "." in [lsv]apply()
Simon, Thanks for replying. In what follows I won't try to argue (I understood that you find this a bad idea) but I would like to make clearer some of your point for me (and may be for others). Le 16/04/2020 ? 16:48, Simon Urbanek a ?crit?: > Serguei, >> On 17/04/2020, at 2:24 AM, Sokol Serguei <sokol at insa-toulouse.fr> >> wrote: Hi, I would like to make a
2005 Mar 15
15
Web-based Ruby Syntax Highlighter
Hi all, Last night, I wrote a web-based syntax highlighter that takes Ruby and produces nice HTML of the code, ready for including on web pages, or in blog posts, or whatever. I don''t know how useful it will be for other people, but feel free to use it. Anyway, the URL is : http://syntax.carldr.com/ Any comments/suggestions would be gratefully received. Enjoy!
2020 Nov 18
3
Best practice preparing for disk restoring system
I'd agree with you John. I'm trying to get away from Amanda's unpredictability and go back to using scripts to drive dump (for ext2/3/4) and xfsdump (for xfs). Is there any easy way to tell rear to include xfsdump and dump capability? If the commands are there then its trivial to restore data. What I've done in the past is before the nightly backup write a small file to the
2006 Jun 26
4
Counting Associated Records from MySQL Result
Hey All, I''m currently working on a Guitar Reviews website and I think i''ve been coding for way to long and forgot the basics..I''m having trouble doing a simple SQL method. I have 2 Tables, 1 for Guitar Manufacturers (gmanufacturers) and 1 for Guitar Models (gmodels), every model has a manufacturer and every manufacturer has many models (gmodel belongs_to