stavro / arc

:paperclip: Flexible file upload and attachment library for Elixir
1.16k stars 210 forks source link

Have a little problem with phoenix 1.3 #221

Open ChrisZou opened 6 years ago

ChrisZou commented 6 years ago

After run mix arc.g avatar, the generated Avatar module is put in app_root/web/uploaders/. while in a newly created Phoenix 1.3 app, the app_root/web is not used by default, and the corresponding folder is app_root/lib/appname_web, e.g. blog/lib/blog_web. As a result, it shows (UndefinedFunctionError) function MyApp.Avatar.store/1 is undefined (module MyApp.Avatar is not available) when I call Avatar.store(...)(I did alias MyApp.Avatar first). Although after moving the file to app_root/lib/appname_web manually, it works fine. It did take me sometime to figure out the problem. So I think it would be nice to move the generated file to app_root/lib/appname_web/uploader, or at least mention this in the guide?

max-bertinetti commented 6 years ago

@ChrisZou When I save data I get this exception: Protocol.UndefinedError at GET /packages/1 protocol Phoenix.HTML.Safe not implemented for %{file_name: "Golf-Club-Green-icon.png", updated_at: #Ecto.DateTime<2017-10-13 13:10:15>}. This protocol is implemented for: Atom, BitString, Date, DateTime, Decimal, Ecto.Date, Ecto.DateTime, Ecto.Time, Float, Integer, List, NaiveDateTime, Time, Tuple The file name is saved with: Golf-Club-Green-icon.png?63675119415 have you had the same issue?

ChrisZou commented 6 years ago

@CodelessFuture No. I think that was a different issue.

acrolink commented 6 years ago

I agree with @ChrisZou .. Should be tuned to the new Pheonix 1.3 folder structure.

sljuka commented 6 years ago

Second this. Also regarding arc_ecto package. I Was getting this error: invalid or unknown type MyApp.PositionPhoto.Type for field :photo until I moved the generated file to /myapp_web folder and changed the module from MyApp.PositionPhoto to MyAppWeb.PositionPhoto, then it worked. Nice library BTW. Sorry for complaining without doing a PR. 😛