Errors
undefined function xxx_path/3 |
add the resource to the router ( resources "/xxx", xxxController) |
cannot use ^xxx outside of match clauses |
add import Ecto.Query to the controler |
hex.pm gotchas
password resets: when you forget a password and reset it, you have an option to revoke api keys, which is default, you must regenerate an api key via cli: mix hex.user auth
errors: inserted_at: can only modify a release up to one hour after creation
if you get this error it is because you didnt update the current version within 1 hour, so you need to bump the version located in mix.exs |
phoenix gotchas
to render a different view/template combo for a controller
conn
|> put_view(xxxWeb.xxxPartialsView)
|> render("xxx.html", assigns: assigns)
to not render templates for only certain controller actions
plug :put_layout, false when action in [:xxx, :yyy ]
to render certain layout for only certain controller actions
:put_layout, {xxxWeb.xxxView, :layout} when action in [:xxx, :yyy]
in order to use https, the config goes into xxxWeb/config/xxx.exs |
|
|
Elixir Gotchas
to access a config
var config = Application.get_env(:my, :title) |
|
|
ecto gotchas
cast_assoc/3 is only used in the changesets of schemas that have has_one or has_many. It invokes the cast/3 validation in the changeset of the associated schema.
assoc_constraint/3 is used in the changesets of schemas that have belongs_to. It checks to make sure the parent schema is in the database so an orphaned record isn't inserted.
foreign_key_constraint/3 is used similarly to assoc_constraint/3, except that it uses the database to validate the foreign key constraint, whereas assoc_constraint/3 uses the Ecto schema definition. |
Brunch Gotchas
bundling stylesheets:
in phoenix 1.3 to bundle a custom directory it has to be both added to watched as well as the jointo under stylesheets the parent dir is app/assets and is implied
in this example we are bundling xxxweb/assets/bundled/page/*.css to xxxweb/priv/static/css/page/vendor.css
ex: for css
joinTo: {"css/page/vendor.css": /^bundled\/(?:css\/)?page/},
watched: ["static", "css", "js", "vendor","bundled"],
for the js i typically separate what i want bundled into a bundled dir, we also need to include node_modules we do so like this.
ex for js.
"js/user/vendor.js": /^(bundled\/js\/user|vendor|deps|node_modules).*/,
but we also need to join the main file responsible for importing the channels etc typically called app.js we do so by adding the path to this file to the modules:autorequire it is important to remember the path is pre compiation, (this took days to understand this) compiling like this.
ex.
modules: {
autoRequire: {
"js/user/vendor.js": ["bundled/js/user/app"],
}
}, |
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment