Thats extremely helpful - thanks. I can see where my expectations are wrong now. I like @kevinpfromnm's suggestion to use "required" as if it is an option has component; used like that it is more "natural" for users, I suspect.
I'd like to suggest that a bit of a documentation tweak would help - us newbies do rely on tutorials and can be disheartened and put off when extending what we're shown doesn't work. One example showing how to mix :required with option hashes should be a good pointer? Thanks so much for your generous help. Much appreciated. On Jan 3, 7:22 pm, Tomoaki Hayasaka <[email protected]> wrote: > > Hi - I was expecting the handling to be more along the lines > > of ":required is a new value in the hash". > > I would agree that it is really confusing for programmers who has no > Rails background, though I don't know if I can call it a documentation > bug. If you know it, it's obvious, but if not, it's not. Here are > some hints: > > - .rb files are Ruby files. DSL fragments such as field > declarations of Hobo Fields, assocations (has_many, etc.) and > validations (validates_presence_of, etc) are all syntactically > valid Ruby expressions. > > - Rails uses "hash as a named option" feature throughout the API. > A `:key => something` argument is probably a named option and you > should place it as the last argument of the method call. Simple > `:key` argument (without associated value) is not a hash and it > won't be a named option. There are some exceptions such as > `button_to(name, options = {}, html_options = {})` helper where > two hashes are expected and you must sometimes explicitly place > surrounding braces to solve ambiguities. > > > Even stuff like > >http://api.rubyonrails.org/classes/ActiveRecord.ConnectionAdapaters/T... > > doesn't mention that the :scale and :precision have to come > > last because they are in a named option hash. > > The method signature `column(name, type, options = {})` and the > descriptions in > http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/Ta... > tell you that `name` should be provided first, `type` should be > second, and options hash may be followed and the options may contain > `:scale => something`. > > ----- > Tomoaki Hayasaka <[email protected]> -- You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.
