#apache #archlinux #asterisk #centos #debian #gentoo #haskell #kde #kubuntu #lisp #math #mysql #perl #python #ruby-lang #rubyonrails #suse #ubuntu #vim #wikipedia 0 1 2 3 4 5 6 7 8 9 10 11 12 13 
Top Prev 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 Next

#rubyonrails

<jstew> that is what an orphaned record is traditionally
<slidge> jstew: won't sql throw a fit if the Message being created doesn't have a request
<jstew> if you do not want NULL for foreign key you could create a joint model and do a has_many :though
<jstew> s/joint/join/
<slidge> wouldnt I at somewhere along the chain though have to be breaking relational integrity?
<jstew> not with a join table
<slidge> so create 1 entry in the join table for every Message that has a Request
<slidge> ?
<jstew> if you want orpan messages without null foreign keys thats what you need
<slidge> would I need a model file for the join in that in app/models?
<jstew> create table requestmessages do |t| t.column "request_id" t.column "message_id"
<jstew> then your join model for that would be belongs_to :request, belongs_to :message
<slidge> isnt there some type of implicit join model system
<slidge> where if I just say has many through it will automatically use that join table?
<jstew> yes, but you need the has_many requestmessages first
<slidge> what about the Message model, will that have anything in it?
<jstew> in order to get the request association you need a has_many :through on that model also
<slidge> cool i'll give it a try, thanks for the help
<jstew> I wish there were a belongs_to :through
<slidge> yea I have wanted something like that for some STI style stuff
<jstew> message.request.first does not seem all that elegant
<slidge> well it would be message.requests.first right? you could just make a request method
<jstew> correct
<jstew> my bad
<slidge> thats still dirty though
<tavilach> so jstew, i think that at this point i want to have an in-place editor for my jokes, and when i press update, i dont want the entire list page to reload. do i need to download the scriptaculous in-place editor code to do that?
<Skiz> jstew: you can create an accessor
<Skiz> or a custom association
<Skiz> ex. message.first_request
<kain> what's the best way to set a single boolean to true? like @article.set_read
<kain> in model
<kain> I don't care about updated_at field
<kain> but it will be better if updated
<Skiz> kain: I like a def was_read!;; ;;end ;;
<Skiz> err
<Skiz> kain: I like a def was_read!;; update_attribute(:is_read, true) ;; end
<pstickne> that's a tone of semis
<pstickne> *ton
<kain> thanks :)
<pstickne> reminds me of lisp comments
<jstew> lol
<Skiz> lol I was missing the guts. ;; is pretty standard for \n in irc
<victori> concerning activerecord on a many to one relationship , has_many :xxx does it cascade delete?
<tavilach> guys, i want to have in-place editing inside my list view, is that really hard to do?
<Skiz> at leasy for ruby or single like ruby
<pstickne> Skiz, ohh.
<Skiz> like/line
<jstew> tavilach: It
<jstew> sorry, it's desribed well in the rails recipes book
<pstickne> victori, there is a flag you can set, I forget what it's called though, check the API

Previous Page  Next Page

Search ircarchive.info