On 15/04/2011, at 11:25 AM, Julio Cesar Ody wrote:
I'm all for what the author likes, so that's a good enough reason for
him to stick to symbols. But this being a DSL and all, and the fact
it'll be declared at load time, nice is what this should be all about
:)
Can't say I agree or disagree really in the general case.
Some DSLs create things you must reference at run time,
again using either symbols or strings, so that can sway the
balance.
Clifford Heath.
On Fri, Apr 15, 2011 at 11:22 AM, Clifford Heath
<clifford.he...@gmail.com> wrote:
On 15/04/2011, at 11:14 AM, Dave Newman wrote:
I still like symbols just because though...
+1
Symbols don't look as nice, but they cost less, because Ruby doesn't
need to construct a new mutable instance every time you execute that
line of code, as it does with strings.
Not usually a problem in a DSL, but still something to think about.
Clifford Heath.
On Fri, Apr 15, 2011 at 11:05 AM, Julio Cesar Ody <julio...@gmail.com
>
wrote:
Here's my take:
class Stuff
fields do
singleline 'code'
multiline 'itinerary'
age_range 'age', label: 'Infante age range'
options 'size', options: %w(Small Medium Large)
end
end
Some thoughts:
- Don't use symbols just because.
- Have label be extrapolated from the field name, unless specified
otherwise.
- Use Ruby 1.9.
On Fri, Apr 15, 2011 at 10:54 AM, Dave Newman <ddanger...@gmail.com>
wrote:
I'll probably keep the field definitions in code for now. To
define them
I'm
thinking a DSL along the lines of this:
def field_definitions
FieldDefinitions.create do
category :tour do
single_line :code, :label => 'Code'
multiline :itinerary, :label => 'Itinerary'
age_range :age_range, :label => 'Infante age range'
options :size, :label => 'Size',
:options => %Q{Small Medium Large},
:default => 'Medium'
end
end
end
Love me some instance_eval!
On Fri, Apr 15, 2011 at 10:10 AM, Michael Cindric
<michael.cind...@sentia.com.au> wrote:
Its a good way to go. We did something similar for a client
rendering
out
dynamic data.
The only thing l would do different is find a better way to
define the
fields so that you dont have to manage them in the class but
rather a
more
dynamic way should the types of products change alot
On 15/04/2011, at 9:50 AM, Dave Newman wrote:
I have a design issue I want to walk through.
I'm building a Rails 3 app which will hold products from a
variety of
different companies. I'd like to define a large set of fields
and each
product can select the fields that are applicable to it.
The field types will be single line text fields, multi line text
fields,
radio or select options, checkbox options, dates, durations or
something
more custom. I'll need to be able to dynamically render the fields
based on
this type for edit and show.
My current idea is to use MongoDB and store everything in a Hash
on the
Product.
....
I just created this on
stackoverflow:
http://stackoverflow.com/questions/5670975/dynamic-fields-with-rails-3
Looking for any and all suggestions, critiques and criticisms!
--
Dave Newman ∴ http://whatupdave.com ∴ @whatupdave
--
You received this message because you are subscribed to the Google
Groups
"Ruby or Rails Oceania" group.
To post to this group, send email to rails-oceania@googlegroups.com
.
To unsubscribe from this group, send email to
rails-oceania+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rails-oceania?hl=en.
Kind Regards,
……………………………………..
Michael Cindrić | Sentia
Software Developer
e: michael.cind...@sentia.com.au | t: +61 2 8003 5216 | m:
0403 526
226 | f: +61 2 9223 4151
www.sentia.com.au
IMPORTANT
This message contains privileged and confidential information
intended
only for the use of the recipient. If you are not the intended
recipient of
this message you are hereby notified that you must not
disseminate,
copy or
take any action in reliance on it. If you have received this
message in
error please notify sentia immediately.
--
You received this message because you are subscribed to the Google
Groups
"Ruby or Rails Oceania" group.
To post to this group, send email to rails-oceania@googlegroups.com
.
To unsubscribe from this group, send email to
rails-oceania+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rails-oceania?hl=en.
--
Dave Newman ∴ http://whatupdave.com ∴ @whatupdave
--
You received this message because you are subscribed to the Google
Groups
"Ruby or Rails Oceania" group.
To post to this group, send email to rails-
ocea...@googlegroups.com.
To unsubscribe from this group, send email to
rails-oceania+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rails-oceania?hl=en.
--
You received this message because you are subscribed to the Google
Groups
"Ruby or Rails Oceania" group.
To post to this group, send email to rails-oceania@googlegroups.com.
To unsubscribe from this group, send email to
rails-oceania+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rails-oceania?hl=en.
--
Dave Newman ∴ http://whatupdave.com ∴ @whatupdave
--
You received this message because you are subscribed to the Google
Groups
"Ruby or Rails Oceania" group.
To post to this group, send email to rails-oceania@googlegroups.com.
To unsubscribe from this group, send email to
rails-oceania+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rails-oceania?hl=en.
--
You received this message because you are subscribed to the Google
Groups
"Ruby or Rails Oceania" group.
To post to this group, send email to rails-oceania@googlegroups.com.
To unsubscribe from this group, send email to
rails-oceania+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rails-oceania?hl=en.
--
You received this message because you are subscribed to the Google
Groups "Ruby or Rails Oceania" group.
To post to this group, send email to rails-oceania@googlegroups.com.
To unsubscribe from this group, send email to rails-oceania+unsubscr...@googlegroups.com
.
For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en
.
--
You received this message because you are subscribed to the Google Groups "Ruby or
Rails Oceania" group.
To post to this group, send email to rails-oceania@googlegroups.com.
To unsubscribe from this group, send email to
rails-oceania+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rails-oceania?hl=en.