[Rails] Is this a use case for an engine or a railtie and why/how?

2012-11-02 Thread Frank Mattia
I have the following files and would like to somehow package them together in a gem however I'm unsure of what I need to create. An engine, a railtie, or something completely different? /lib/unit.rb A unit class to handle a common requirement across my models /app/concerns/unitify_concern.rb

Re: [SOLVED] [Rails] Saving values to the db as metric but displaying/editing in imperial.

2012-11-01 Thread Frank Mattia
> private > def update_diameter_in_units > write_attribute(:diameter, Unit.to_db(diameter_in_units)) > end > end On Thursday, November 1, 2012 3:48:55 PM UTC-4, Frank Mattia wrote: > Thanks Scott, > > I'm closer but not quite there. I had originally tried virtual attribute

Re: [Rails] Saving values to the db as metric but displaying/editing in imperial.

2012-11-01 Thread Frank Mattia
n you always reference f.text_field :DiameterStr. > > You could always play around with making the underlying attributes > private, or at least a diameter= method which throws an exception... (Which > slightly complicates DiameterStr=...) > > On Oct 29, 2012, at 5:57 PM, Frank Mattia

[Rails] Saving values to the db as metric but displaying/editing in imperial.

2012-10-29 Thread Frank Mattia
I have a requirement to store values in a database as unitless decimals(12,9) which will be presumed to be metric values. For display/editing purposes I need the user to be able to choose their input method -- no mixing and matching on a form, just a simple User#current_units call to determine

[Rails] Re: extracting a portion of a model to a separate file

2012-10-25 Thread Frank Mattia
Matt Jones wrote in post #1080951: > On Friday, 25 June 2010 01:12:47 UTC-4, frankj...@gmail.com wrote: >> I have a ton of models that each have fairly complex state machines. >> >> My state_machine blocks however are very large and clutter up my >> model.rb files... >> >> What I want to do is extr

[Rails] Re: extracting a portion of a model to a separate file

2010-06-25 Thread Frank Mattia
Marnen Laibow-Koser wrote: > frankjmat...@gmail.com wrote: >> On Jun 25, 9:58�am, Marnen Laibow-Koser wrote: >>> > I have a ton of models that each have fairly complex state machines. >>> >>> >>> >>> >>> > What I want to do is extract out all of the state machine code to >>> > another file that I