#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
Top Prev 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 Next
#rubyonrails
<ReinH> you're using current_series as an iterator
<zachinglis> :)
<ReinH> why are you using that ugly iterator?
<ReinH> there's always a better way to iterate in ruby
<ReinH> *almost* always
<lal00> In a before_update function I want to do something if the value of an attribute has changed. How can I test this ?
<smtlaissezfaire> ReinH: because that is the iterator in the scaffolding code
<ReinH> check it against the current value in the database
<ReinH> smtlaissezfaire: you're kidding
<smtlaissezfaire> I've never seen that before the scaffolding code and never seen it since
<ReinH> I don't remember that
<ReinH> Then again, I haven't looked at scaffolding code in months
<invalid8> anyone mind helping a newb out?
<invalid8> http://pastie.caboo.se/41286
<ReinH> I knew the scaffolding code was a bit inelegant, but that's ridiculous
<invalid8> i can't seem to get instance variables passed to views since upgrading to rails 1.2.2
<smtlaissezfaire> yeah! crazy, isn't it! What's also really strange is that the old scaffolding code has all of these pseudo-meta programming things...like Model.content_columns, and self.class.to_s
<lal00> ReinH, how ?
<ReinH> lal00: read_attribute
<invalid8> i've got no idea what the layoutfalseaction means
<ReinH> invalid8: let's see the controller action too
<ReinH> smtlaissezfaire: yeah, but self.class.to_s is useful
<invalid8> ok, you'll have to refresh the url
<ReinH> the whole iterating over content_columns is a neat hack, but it's more to show off than actually useful
<smtlaissezfaire> sure. It's a good thing to know. So is self.class.content_columns
<invalid8> @mortgage_total is always showing up as nil
<invalid8> in the view
<aliekens> about 8 hours left before i have the 2nd edition of the agile book ... this first edition is getting on my nerves (i now understand my problems with components, 1st edition put me on the wrong track ...)
<ReinH> invalid8: put the render at the bottom
<smtlaissezfaire> But who actually uses stuff like that? You Call User.name - you don't iterate over User.content_columns unless you are doing something really interesting
<ReinH> smtlaissezfaire: like I said, it's a neat hack, but it's basically just a show off
<ReinH> You don't do that in any real app
<smtlaissezfaire> of course not. maybe in a plugin, though.
<smtlaissezfaire> Or, if you want to modify rails itself you better know stuff like that
<invalid8> ok
<ReinH> well, it's simple enough, it's just not that useful
<smtlaissezfaire> What is really a shame about about that damn screen cast is that makes rails look like pressing a button. Then the a newbie generates some scaffolding code and seems some advise about changing it.
<ReinH> It doesn't handle attr_allowed or attr_protected, for instance
<ReinH> yeah true enough
<smtlaissezfaire> Except that the scaffolding code has strange idioms like for item in items
<ReinH> I wish the scaffolding had been better updated for just that reason
<ReinH> yeah, that's an attempt to appeal to crossovers from languages that use the for loop
<invalid8> updated the pastie
<ReinH> for item in items does items.each do |item| internally anyway
<ReinH> invalid8: no, I mean put the render :layout => false at the bottom of the action
<ReinH> the .each iterator is one of the most beautiful things about ruby though, it's a shame not to use it
<smtlaissezfaire> but I must say, when I started, I had no idea how OOP worked. I had no idea what the new method was, that it created an instance of the class. No idea even what a class was, although I had some vague notions from a high school class on C++
<invalid8> wh00t
<smtlaissezfaire> that for x in y must be a rails construct?
<ReinH> smtlaissezfaire: no, it's not, it's a ruby construct
Previous Page Next Page