| baggito | so the blog table has a blogger_id ? |
| GaryKing | baggito: it has a editor_id, which is what I specified that's what the :foreign_key is for :) |
| baggito | i mean in the blog table |
| GaryKing | baggito: I know baggito: blog.editor_id exists |
| baggito | maybe you want to specify belongs_to :blogger, :foreign_key => :editor_id then |
| GaryKing | blog.editor_id => blogger.id baggito: I tried and then my app crashed.. let me try again.. |
| baggito | crashed? |
| GaryKing | baggito: nevermind, worked this time :) thanks now I have another, much more scathing issue to deal with.. argh.. o_O |
| baggito | ok |
| GaryKing | baggito: Does :foreign_key ALWAYS go with belongs_to? baggito: Because for another one, that's not the case, and if I move the :foreign_key to belongs_to, then my app gives me an error. |
| baggito | only if it's not named logically if you called editor_id blogger_id, i think it should work |
| GaryKing | baggito: I know I only use it when it's not called logically :) baggito: I have this: "has_many :blogger_details, :foreign_key => 'user_id'" and this: "belongs_to :blogger" is that okay? |
| baggito | well it depends doesn't it |
| GaryKing | baggito: On what in particular? |
| baggito | well, if the key is not named <foreign-table>_id then yes |
| Glenn_NZ | Gosh, you guys are up late then :) |
| baggito | it's 22:26 here in lima |
| GaryKing | How do I use .is_a?(Integer) with params when params are always strings even if it's a number? something like is_numeric would be nice :) |
| pstickne | GaryKing, huh? |
| GaryKing | pstickne: I want to check if the :id is an integer, like I have /show/all or /show/1 |
| pstickne | just to_s it and if it's 0 (or invalid), then shame on them Integer(p) rescue nil # one way |
| GaryKing | neato |
| pstickne | but in general, just convert it and treat it and then act, don't worry about "checking the type" so much |
| GaryKing | /show/all looks cleaner than just /show/ :) |
| pstickne | maybe handle that in routing? (then you won't even get an id of "all") and if you do, when it is to_i, it will be 0 and things will work out accordingly |
| GaryKing | pstickne: I'm not all that familiar with routes.rb :/ I only know how to set the default one |