ruby-hyperloop / hyper-mesh

The project has moved to Hyperstack!! - Synchronization of active record models across multiple clients using Pusher, ActionCable, or Polling
https://hyperstack.org/
MIT License
22 stars 12 forks source link

add `#html_attr_name` method #62

Open catmando opened 6 years ago

catmando commented 6 years ago

just a handy helper to add the ActiveRecordBase (on the client) (it would jus be added to InstanceMethods module)

  def html_attr_name(attr)
    "#{model_name}#{to_key}-#{attr}"
  end

See https://github.com/ruby-hyperloop/hyper-react/issues/244 for details on to_key

sfcgeorge commented 6 years ago

This seems less useful than to_key unless for and name params do some magic, which I think they probably shouldn't. As there's no obvious "right" way of naming for/name in HTML (there's probably multiple competing conventions like there are with BEM/OO CSS etc), so I guess many would override this anyway, so we could just leave them to add it in ApplicationRecord themselves.

If Hyerloop had its own form_builder replacement smart input components then this would be a part of it.

But a one size fits all form builder is hard. The Rails one isn't flexible enough to work with frameworks like Bootstrap, so then there was SimpleForm but that's nowhere near simple, I hate it. I'd suggest holding off on this issue until we have a more concrete use-case for it.

catmando commented 6 years ago

are the conventions used by any code? As in would I ever "have" to use the convention, or is it just simply a convention to keep things tidy. In which case it seems like it might be helpful. but I dunno. We can drop it from 1.0 if all agree...

sfcgeorge commented 6 years ago

See https://github.com/ruby-hyperloop/hyper-react/issues/245 for how I use this in a smart form input component. Simply some human readable and useful yet unique identifier to link name and from