Skip to content

Instantly share code, notes, and snippets.

@alxjrvs
Last active August 29, 2015 14:03
Show Gist options
  • Save alxjrvs/be69ab1f2ee27f5b51d3 to your computer and use it in GitHub Desktop.
Save alxjrvs/be69ab1f2ee27f5b51d3 to your computer and use it in GitHub Desktop.
#If you are setting a custom folder for Carrierwave uploads and that folder structure relies on related objects,
# be sure that those related objects are already created before initializing the carrierwave object!
##This is bad
User.create(
username: "cosby",
avatar: Avatar.create(file: <a file>)
)
##This is Good
user = User.create(username: "cosby")
user.build_avatar(file: <a file>)
user.save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment