Displaying 17 results from an estimated 17 matches similar to: "has_many and belongs_to example?"
2006 Mar 13
2
relationship woes
I have two tables:
class PgmUpdate < ActiveRecord::Base
has_many :pgm_visits, :foreign_key => ''pgm_update_fk''
...
and
class PgmVisit < ActiveRecord::Base
belongs_to :pgm_update, :foreign_key =>
''pgm_update_fk'', :dependent => true
...
According to the has_many docs (http://api.rubyonrails.org/classes/
2006 Mar 14
1
Where to validate?
class PgmUpdate < ActiveRecord::Base
has_many :pgm_visits
...
class PgmVisit < ActiveRecord::Base
belongs_to :pgm_update
...
I am trying to make sure that none of the visits in PgmUpdate overlap
start and end dates. Should this validation exist in PgmUpdate or the
controller? It seems natural to put them in PgmUpdate, but I must
force the relationship together because
2006 Feb 27
6
One to Many example... please!
Hi,
I am pulling my hair out trying to work out how to put together what
should be a simple app in rails. The app is to CV''s so I have a table of
CV''s and each CV can have multiple skills. Skills are in a 2nd table
below;
CREATE TABLE cvs(
id INT not null AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(30) not null,
family_name VARCHAR(30) not null,
email
2008 Jul 08
12
Some more win32-security: SID.create
Hi all,
How does this look as a general approach to a SID.create method:
# Creates and initializes
def self.create(authority, *sub_authorities)
if sub_authorities.length > 8
raise ArgumentError, ''maximum of 8 subauthorities allowed''
end
authorities = Array.new(8, 0)
authorities.replace(sub_authorities)
count = authorities.select{ |e| e > 0 }.size
2006 Mar 04
1
validation for items in a 1 2 many
I am populating a table skills which relate to a table cv in a 1 cv to
many skills relationship...
I populate the skills as below;
def new
@session[:cv_id] = params[:id]
@skill = Skill.new
end
def create
@cv = Cv.find(@session[:cv_id])
@cv.skills << Skill.new(params[:skill])
if @cv.save
flash[:notice] = ''Skill was successfully created.''
2006 Aug 24
3
A new QueueWorker class
Hello all,
I''ve come up w/ a worker class that manages queued jobs using a fixed
number of child workers. Well, that''s not quite true -- a new worker is
spawned for each job, but you set the total number that may exist at once.
There are three components:
1) queue_worker.rb: The singleton worker that manages the child workers.
You probably want to auto start this. Make sure you
2006 Feb 28
6
Problem with select and each_with_index
Disclaimer: Ruby newbie at work
Thought I was going so well. Wanted to produce a select box from an
array constant, with the indices returned as values , and the array
values used as the descriptions. Checked out Ruby RDoc and saw there was
an each_with_index method and came up with:
<%= select (''type'', ''typecategory'', Typecategory.each_with_index
2006 Jan 17
8
Next Record
Okay, I know this will probably be a very easy question. But I am
discovering that RonR makes just about everything easy. The problem is,
it takes me a few hours to figure out that I can do it the easy way.
I need to know how to move to the next record in a database. I want to
format my out put in a table. For example, I want a 3 by 3 table. So
record one goes in the first cell, record
2006 May 31
7
How do you create a controller & view to create a list of objects?
I''m trying to figure out how to design a view and controller to work with a
simple collection. I have a Foo that has many Bars, so here''s what I did:
$ ruby script/generate model Foo
$ ruby script/generate model Bar
(Uncomment t.column, :name: :string in foo and bar migrations)
(Edit Foo.rb and Bar.rb, add has_many :bars to Foo, belongs_to :foo to Bar)
$ rake db:migrate
$ ruby
2009 Jan 29
4
Help understanding EVERYTHING
Team,
I am trying to learn a GUI for Ruby and I picked wxRuby.
The problem is that I am kind of slow learning this and I now feel
frustrated after trying for about at least 7 hours.
I am trying to design a simple Sudoku 9x9 grid to display numbers, 1 - 9,
using buttons.
I posted a question on Ruby forum ruby-talk and a gentleman, Alex Fenton,
answered my questions.
Alex gave me what appear to be
2006 Apr 28
7
acts as drop down
Hi
Im using the acts as drop down plugin
and have this code below
acts_as_dropdown :text => "forename", :order => "forename"
It currently makes use of the forename in the option tag, how can I get
it to use the surname as well
ie somthing like ''forename'' . ''surname'' in php
Thanks
--
Posted via http://www.ruby-forum.com/.
2008 Mar 16
8
include a page in another
Hi,
for my isbn plugin, I''m wishing to incldue generated isbn pages in
caller pages (the ones with <isbn value=""> tags).
But I want my isbn page to be processed before for its tags to be
transformed (like the relocatable or other ones). Besides, i do not
want its header to be included.
Is there an easy solution for that, or should I do the work myself ?
--
Nicolas
2004 Feb 24
3
problem of install.packages in windows (R 1.81)
Dear R users,
I have a problem in the configuration of R:
I just changed university, and my conection to the net is via a password, which
permits me to access the packages with no problem via the internet explorer
(version 6).
I just updated R to R 1.81, and I cannot download nether upgrade packages (and
many are not working with the update!!!).
I have been looking in the help and emails, and
2001 Apr 27
0
emtpy directory after install of Windows Application
Hello,
I'm fairly new to Linux and I like it a lot. Unfortunately some of my
favorite
applications are Windows based, so I started looking into Wine. I don't have
a Windows installation.
I got a few 16 bit and 32 bit applications to work, but as soon as I try to
set up an application that tries to write files into a folder with spaces,
like 'Program Files', the destination
2006 Apr 21
0
model modules
I have a need to subclass models a lot and I thought modules would be
the way to go, but I am encountering nothing but trouble with them. I
seem to be getting stuck with storing an object in the session, but
on the next request it can no longer read the session data and
creates a new session. Any other time I use the model it works just
fine. I read "Agile Web Development With
2006 May 15
0
acts_as_list, move_higher, odd indexing behaviour?
Hi,
[reposting to list, posting via google groups apparently didn''t work]
I''m trying to use acts_as_list for the first time.
Can anyone confirm the odd behaviour reported here?
http://blog.nominet.org.uk/tech/Web/2006/03/06/Using_acts_as_list_in_...
i.e. element access and move_higher require an odd indexing scheme to
work.
I''m personally finding that I
2008 Jan 09
0
odd manifest problem
So I''m having some problems with some of my manifests that I''ve been using
for a while and I''m not entirely certain what''s going on.
What appears to be happening is that puppet when it runs can''t see the value
for one of the default facter facts (domain). I''m not real certain that
this is the actual problem I think this is just how