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

Legacy with rails4 branch 'changed' issue #367

Closed
lustremedia opened this issue Nov 7, 2013 · 8 comments
Closed

Legacy with rails4 branch 'changed' issue #367

lustremedia opened this issue Nov 7, 2013 · 8 comments

Comments

@lustremedia
Copy link

I have a legacy table with a column name changed which is reserved by ActiveRecord

ActiveRecord::DangerousAttributeError in Events#show
changed is defined by Active Record

How can I tell oracle enhanced adapter to use a different name for that column name?

Is there something like self.column_name changed, AS othername

It would also be good to have this in the legacy documentation if it exists ...

@PavelPenkov
Copy link

Use safe_attributes gem https://github.com/bjones/safe_attributes

@yahonda
Copy link
Collaborator

yahonda commented Nov 7, 2013

Hi, #182 has been merged in v1.5.0 release which just supports Rails 4. You can have a column name changed.

Would you tell me the exact rails version?

@lustremedia
Copy link
Author

Hi I am using Rails 4.0.0 and v1.5.0. I just upgraded to 4.0.1 and I am testing to let you know if something has changed.

@lustremedia
Copy link
Author

Ok I still get ActiveRecord::DangerousAttributeError with changed is defined by Active Record

Rails 4.0.0 and 4.0.1
OracleAdapter ~> 1.5.0

@yahonda
Copy link
Collaborator

yahonda commented Nov 8, 2013

Thanks for the update. It's my bad. #182 has nothing to do with your question, it allows to create a column named "FIELD".

I also find Rails 4.0.1 with sqlite3 as database, ActiveRecord::DangerousAttributeError generated after this migration.

$ rails g scaffold item name:string changed:string

So I can say there is no oracle-enhanced specific tips to create a table with changed columns.

As @PavelPenkov kindly commented to use safe_attributes gem to workaround this error. It looks it allows you to do so. https://github.com/bjones/safe_attributes/blob/master/spec/safe_attributes/safe_attributes_spec.rb#L10

or contact https://groups.google.com/forum/#!forum/rubyonrails-talk mailing list for wider knowledge.

@lustremedia
Copy link
Author

Ok thanks. It looks like I can set the column to ignore in my case. So there is also no way to set an alias for a column name, sort of like an changed AS mychanged?

@lustremedia
Copy link
Author

@PavelPenkov @yahonda safe_attributes is not supported by Rails 4 as per bjones/safe_attributes#9 so that is not going to help but I would close the issue since it is not related to oracle enhanced but rather ActiveRecord ...

@yahonda
Copy link
Collaborator

yahonda commented Apr 25, 2015

Closed.

@yahonda yahonda closed this as completed Apr 25, 2015
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

No branches or pull requests

3 participants