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

Attr accessible in rails 4 #1368

Closed
devmug opened this issue Oct 26, 2013 · 6 comments
Closed

Attr accessible in rails 4 #1368

devmug opened this issue Oct 26, 2013 · 6 comments

Comments

@devmug
Copy link

devmug commented Oct 26, 2013

Quick Start

In your model:

class User < ActiveRecord::Base
attr_accessible :avatar

Could you please put a note for rails 4 users not to add attr accessible .. causes a
undefined method `flush_errors' for #<ActionDispatch::Http::UploadedFile
and it took me a good 2 hours to work out what was happening.

Thanks

@kyivcookie
Copy link

I got this error too. devmug are you solved the problem?

@kyivcookie
Copy link

UPD. Solved, in Model, u must place the paperclip validation after all others validations

@sikachu
Copy link
Contributor

sikachu commented May 8, 2014

@AndreyPristupa we'd love to have more info on this. By 'others validation', what are the rest of validations you have in there?

Also, I assume you don't need attr_accessible if you already use Strong Parameters?

@kyivcookie
Copy link

validates :name, :start_at, :end_at, :description, presence: true
validates :name, length: { in: 4..100, too_long: I18n.t(:too_long_field), too_short: I18n.t(:too_short_field) }
validates :description, length: { in:100...5000, too_long: I18n.t(:too_long_field), too_short: I18n.t(:too_short_field) }

has_attached_file :image, :styles => { :medium => '300x300>', :thumb => '100x100>' }, :default_url => '/images/:style/missing.png'
validates_attachment_content_type :image, :content_type => /\Aimage/.*\Z/

Work's fine. But:

has_attached_file :image, :styles => { :medium => '300x300>', :thumb => '100x100>' }, :default_url => '/images/:style/missing.png'
validates_attachment_content_type :image, :content_type => /\Aimage/.*\Z/

validates :name, :start_at, :end_at, :description, presence: true
validates :name, length: { in: 4..100, too_long: I18n.t(:too_long_field), too_short: I18n.t(:too_short_field) }
validates :description, length: { in:100...5000, too_long: I18n.t(:too_long_field), too_short: I18n.t(:too_short_field) }

doesn't work, trow: undefined method 'flush_errors'

@maclover7
Copy link
Contributor

Hi @AndreyPristupa and @devmug ! Is this still an issue for you in Paperclip; I know this issue is from approximately 2 years ago. If it is still an issue, can you please provide the code that's causing you the error? Thanks!

@tute
Copy link
Contributor

tute commented May 15, 2015

Given there's no activity around this issue any more, I hope things are working well for you now. I’ll close the issue, happy to continue further discussion if we can find a fix for it. Thanks for your input!

@tute tute closed this as completed May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants