gogogarrett / phoenix_crud

A simple CRUD application using Elixir and the Phoenix framework
66 stars 22 forks source link

User validation removed? #4

Open stochastic-thread opened 9 years ago

stochastic-thread commented 9 years ago

Hey haha, I got your code working (I opened the last issue) but now I'm working through your tutorial (http://gogogarrett.sexy/programming-in-elixir-with-the-phoenix-framework-building-a-basic-CRUD-app/) and writing the code myself to learn Phoenix and Elixir. I have a solid background in Erlang but I'm having some trouble getting it to the current Phoenix version given the breaking changes...

In user.ex I had to change the line of code that is validate user, content: present() because I was getting this error:

Compiled lib/phoenix_first.ex

== Compilation error on file web/models/user.ex ==
** (CompileError) web/models/user.ex:8: undefined function validate/2
    (stdlib) lists.erl:1352: :lists.mapfoldl/3
    (stdlib) lists.erl:1353: :lists.mapfoldl/3

Upon investigation, I realized that it had (maybe?) been changed to: @required_fields ~w(content)

Moving right along, in your tutorial, you then use the User.validate(user) function but I don't know what to change it to given the change in the Phoenix framework that removes the validate function.

I tried to do a simple case match where I match on user, given my initial thought that the model is implicitly doing the validation (with the @required_fields ~w(content)) line of code, but I'm a little stuck.

Any advice?

Thanks very much!

You can find my progress building your tutorial applicaiton here:

https://github.com/arthurcolle/first_phoenix_web_app

mackinleysmith commented 8 years ago

I'm in the same position here and would greatly appreciate some insight.

gogogarrett commented 8 years ago

Sorry all - This project is very out of date, and so is the blog post. I will do my best to get this back up to date now that the christmas season is over.