[Rails] Re: difference between belongs_to and references keyword?
I've written a short example about has_many, belongs_to -
http://gist.github.com/425026
has_many, has_one, belongs_to deffinitions goes into model and not in
scaffold. You can use "references" like this: script/generate scaffold
address company:references address:text
but as I mentioned in this discussion http://railsforum.com/viewtopic.php?id=39325
(look for andain's posts) I'm running into problems where views are
generated without appended _id. Maybe I'm just doing something wrong
or just not getting it right ...
Anyway I hope i shed some light on your problem.
On Jun 4, 2:18 am, Kevin Hastie <li...@ruby-forum.com> wrote:
> Kevin Hastie wrote:
>
> I guess what I really want is something like this:
>
> class Address< ActiveRecord::Base
> belongs_to :addressable, :polymorphic => true
> end
>
> class Business< ActiveRecord::Base
> has_one :address, :as => :addressable
> end
>
> class School < ActiveRecord::Base
> has_one :address, :as => :addressable
> end
>
> h) I don't suppose there is a way to do that with the scaffold. Is
> there a typical set of scaffold options that would map to this?
>
> i) Lastly, I guess I am better off avoiding polymorphism at the
> beginning, huh? I should just be doing a simple mapping...
> --
> Posted viahttp://www.ruby-forum.com/.
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home