Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with phony_normalize on migration #19

Closed
k4nar opened this issue Apr 26, 2013 · 6 comments · Fixed by #20
Closed

Error with phony_normalize on migration #19

k4nar opened this issue Apr 26, 2013 · 6 comments · Fixed by #20

Comments

@k4nar
Copy link
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
Copy link
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 pushed a commit that referenced this issue Apr 26, 2013
Raise only an exception at validation for non-existing attributes (#19)
@joost joost closed this as completed Apr 26, 2013
@JamesCropcho
Copy link

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
Copy link

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

@JamesCropcho
Copy link

...it seems to work, at least.

@joost
Copy link
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
Copy link

@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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants