Error with phony_normalize on migration #19

Closed
k4nar opened this Issue Apr 26, 2013 · 6 comments

Projects

None yet

3 participants

@k4nar
Contributor
k4nar commented Apr 26, 2013

Hello,

Every time I run a migration concerning a model with a phony_normalize, the following exception is raised :

No attribute foo found on Model (PhonyRails)

The exception is raised from lib/phony_rails.rb:73.

A warning wouldn't be enough ? I have to comment every phony_normalize in my models before running a migration, then uncommenting them.

@joost
Owner
joost commented Apr 26, 2013

The phony_normalize class method checks if the attributes it should normalize exist.
We could move the raise to the set_phony_normalized_numbers method so it is raised when the actual attribute is written.

Feel free to create a pull request :)

@joost joost closed this Apr 26, 2013
@JamesCropcho

Hello,

Thanks for the great tool!

#phony_normalize with :as throws "not an attribute" exception when I attempt to create database column.

Upon rake db:migrate and rake db:schema:load:

'customer_contact_phone_number_normalized' is not an attribute on PropertyManager. You might want to use 'phony_normalized_method :customer_contact_phone_number' (PhonyRails)

Makes sense, in a way, since the database column's not yet been created.

However, this does mean I can only run those commands by commenting out #phony_normalize.

Am I doing everything correctly?

Thanks Again,
James

@JamesCropcho

Quick thought- would it help to manually declare customer_contact_phone_number_normalized as an attr_accessor in the model? Thanks!

@JamesCropcho

...it seems to work, at least.

@joost
Owner
joost commented Feb 15, 2014

@JamesCropcho it does indeed. Migrations with conflicting models is an issue that happens more often. We could remove or maybe postpone the check however. Pull request welcome for this :)

@JamesCropcho

@joost I had success with manually declaring as an attr_accessor as described above.

Regarding modification of current behavior- well, I actually like the sanity check you've put in, as is, myself. so I'm loathe to suggest modifying it, now that we have a workaround.

Thanks again for the great tool, sir.

-J

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment