Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Incompatibilities with "service_id" as a column name #36

Closed
mastfish opened this issue Jan 12, 2015 · 4 comments · Fixed by #40
Closed

Incompatibilities with "service_id" as a column name #36

mastfish opened this issue Jan 12, 2015 · 4 comments · Fixed by #40

Comments

@mastfish
Copy link

At the moment, this gem isn't compatible with any rails application that has a table with a column named "service_id".

It throws

ActiveRecord::DangerousAttributeError:
       service_id is defined by Active Record. Check to make sure that you don't have an attribute or method with the same name.

My application has a table with a column name of "service_id", so this is problematic.

@monfresh
Copy link

I'm running into the same issue. Any idea when this will be resolved?

I would recommend renaming service_id to something more unique and preferably without an _id ending since those usually refer to foreign keys. Something like fastly_customer_key, since the Fastly web interface calls it Customer ID, not Service ID.

@monfresh
Copy link

Also, what is the purpose of defining these methods on the Model? If you don't need to override the global service_id, do you still need the Model methods?

And in what scenario would you need to override the global service_id? Is that common?

@set5think
Copy link
Contributor

Hi,

Sorry for the delay in getting to this issue. It's definitely something to resolve. As a simple measure, we will rename this attribute to be much more unique. That should remove the 99% of collision.

since the Fastly web interface calls it Customer ID, not Service ID

The customer id and service id represent two separate things. In the relational sense, a customer has many services.

Also, what is the purpose of defining these methods on the Model? If you don't need to override the global service_id, do you still need the Model methods?

In order to perform surrogate-key purging, you need access to that particular Fastly service's unique identifier. The particular concept of this plugin was to provide simple capabilities to allow easy edge caching and purging at the model level in Rails applications. Depending on the purpose of your application and your usage of Fastly, you may want to be able map models to different Fastly services. If you are interested in more information on all the different Fastly features, definitely check out https://docs.fastly.com/, or get in touch with us, we'd be happy to help.

It's possible there's another implementation that could totally rid us of worrying about collision in any scenario, but it would probably take a bit more rethinking, and renaming seems a lot simpler and easy to resolve the issue at hand.

Thanks again for pointing this issue out.

@monfresh
Copy link

Thanks for the explanation, and the fix! I totally missed that the Customer ID and Service ID are different. Makes sense. Perhaps it would help to add a link to this FAQ in this repo's Readme, and/or add a label for "Service ID" on the Fastly website to make it clearer.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants