Closed RailsCod3rFuture closed 8 years ago
I'm using CarrierWave for uploading photos.
this looks to be the reason: photo: proc {|controller, model| model.photo },
What are you trying to do with this?
Is it necessary to have? Can I just use the tracked method instead? Check my view for listing activities below. Can you provide me with the best approach if this is a tad bit overkill?
Notifications.html.erb <%= render_activities(@activities) %>
_activities.html.erb
You added photo
attachment on your model but haven't modified Activity to have a photo, so you cannot assign it from tracked
. If you want carrierwave attachments on your Activities, follow this guide: https://github.com/chaps-io/public_activity/wiki/%5BHow-to%5D-Use-custom-fields-on-Activity.
Yeah, like @farnoy said. You are trying to assign a photo to Activity, and activity doesn't have that method, which comes from Carrierwave (and having some columns on that table)
Closing as it's not a bug.
ActiveRecord::UnknownAttributeError (unknown attribute 'photo' for PublicActivity::Activity.): in 'create'
Cannot render console with content type multipart/form-dataAllowed content types: [#<Mime::Type:0x3b50128 @synonyms=["application/xhtml+xml"], @symbol=:html, @string="text/html">, #<Mime::Type:0x3b4b610 @synonyms=[], @symbol=:text, @string="text/plain">, #<Mime::Type:0x3b430d8 @synonyms=[], @symbol=:url_encoded_form, @string="application/x-www-form-urlencoded">]
def create @user = current_user @post = @user.posts.build(post_params)
end
private def post_params params.require(:post).permit(:body, :photo) end
def find_post @post = Post.find(params[:id]) end
def correct_user @post = current_user.posts.find_by(id: params[:id]) redirect_to root_url if @post.nil? end
def without_tracking Post.public_activity_off yield if block_given? Post.public_activity_on end
Post.rb include PublicActivity::Model tracked owner: Proc.new {|controller, model| controller.current_user ? controller.current_user : nil }, photo: proc {|controller, model| model.photo }, body: proc {|controller, model| model.body }