On Sat, Feb 25, 2012 at 1:10 AM, Peter Pavlovich <pavl...@gmail.com> wrote:
> Greetings,
>
> I am trying to use the "datepicker" control from the hobo-jquery gem.
> Here is what I have in my application.dryml:
>
> <def tag="input" for="Date">
> <datepicker />
> </def>
>
> And here is what the tag generated:
>
> <input type="text" id="" data_rapid="{"datepicker":
> {"options":{"dateFormat":"yy-mm-
> dd"},"events":{}}}">
There are two potential problems here.
1) it should be data-rapid rather than data_rapid.
2) the " should be \". Hopefully this is a cut and paste problem
rather than a real problem.
#1 looks like bug #994. Is it possible that you're using a version of
Hobo (jquery branch) from before Jan 11? If so, can you bundle
update hobo and try again?
thanks,
Bryan
On Sun, Feb 26, 2012 at 11:12 PM, Peter Pavlovich <pavl...@gmail.com> wrote:
> Greetings,
>
> Sorry for all the questions. I hope you don't mind :)
>
> class Person < ActiveRecord::Base
> has_one :address, :dependent => :destroy, :inverse_of => :person
> end
>
> class Address < ActiveRecord::Base
> belongs_to :person, :inverse_of => :address
> end
>
> Here are my questions:
>
> Are these class definitions set up the right way?
Hobo does not support has-one relationships completely. So if you
want the Hobo magic you have to use has_many and then constrain N to
[0,1] via validations.
Or just move all of the address fields into User.
P.S. good call using inverse_of. It's not strictly necessary in
Hobo but probably would have been if Hobo was first built in 2010
instead of 2007. :)
Bryan
There are two large pieces that would need to be done:
either add has-one support to [accessible
associations](http://cookbook.hobocentral.net/manual/multi_model_forms)
or rip accessible associations out of hobo and rearchitect hobo to use
accepts_nested_attributes_for. The latter is the right thing to do,
the former would be easier.
and
an input-one tag.
>
> In the interim, when you say "constrain N to [0,1] via validations", can you
> point me to an example I can study?
http://apidock.com/rails/ActiveModel/Validations/ClassMethods/validates_length_of
Bryan