Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > newbie: hierarchical object model with RoR

Reply
Thread Tools

newbie: hierarchical object model with RoR

 
 
Adam
Guest
Posts: n/a
 
      05-21-2008
I've read all the simple tutorials and decided to have a go at
building a slightly more complicated application. Unfortunately I
immediately came unstuck. I have three objects, for the sake of
argument they are author, series and book. An author has many series',
and a series has many books. By extension an author also has many
books through series'. This is all fine and groovy, however what I'd
like is to be able to create a new series for an author from the
author's "show" page (if that terminology makes sense, I couldn't
think of a better way to put it), and pass the author's id through so
that the user doesn't have to (and also _can't_) set the author id
manually. Obviously I'd like the same situation with books in series'.
I can't figure out how to do it. I'm almost there, but it's not quite
right and I keep getting errors that suggest to me that I don't have
access to an @Author at the time I'm trying to access it in my
controller. I have something like @author=Authors.find(:author_id)
followed by @series=Series.new(:author_id =>@author). I can't be
absolutely certain because I haven't got the code in front of me at
the moment, but that's the gist. I'm also trying to use RESTful urls,
but not getting very far with that either. I've set up the routes file
so that authors have many series' and series' have many books, and I
can access my books via http://myhost:3000/authors/1/books/1, but the
app doesn't see to use this convention internally, so if I click a
link within my author to take me to his books, I get http://myhost:3000/books/1,
rather than http://myhost:3000/authors/1/books/1.

I've found there's an awful lot of really, really simple tutorials out
there, and an awful lot of stuff that assumes you know roughly what
you're doing, but I can't find anything in between. Can anyone give me
a simple recipe to get these relationships set up the way I want? I'm
sure it's something ridiculously simple that I'm just completely
missing, but it's frustrating me now and rather than bang my head
against the wall for another evening I thought it was prudent to ask.
 
Reply With Quote
 
 
 
 
Robert Dober
Guest
Posts: n/a
 
      05-21-2008
You might want to post this to the RoR mailing list.

Cheers
Robert



--
http://ruby-smalltalk.blogspot.com/

---
Whereof one cannot speak, thereof one must be silent.
Ludwig Wittgenstein

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
automating bringing of signals in hierarchical VHDL model to toplevel entity fearg VHDL 10 08-08-2011 08:37 AM
RoR Problems with special Character in the model Joachim Reichel Ruby 4 06-09-2007 02:58 PM
RoR: model on basis of a view on a LEFT JOIN? harm.hoekstra@gmail.com Ruby 1 11-26-2006 09:05 PM
Convert Java Model to Java Model without XML erinbot@gmail.com Java 1 10-06-2006 09:00 PM
display hierarchical diagram of object =?Utf-8?B?Q3JhaWc=?= ASP .Net 0 04-26-2005 09:07 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57