VincentBlackdot
No function clause matching in SmartcomClientWeb.TemplateController.create/2
hi i am using ajax to post data to my db, but keep running into this error.
no function clause matching in SmartcomClientWeb.TemplateController.create/2
this is my is my ajax code
$("#push_data").click(function() {
params = $("form.form-temp").serialize();
$.ajax({
type: 'POST',
url: '/create/template',
data: params,
success: function (response) {
console.log(response)
},
error: function (error) {
console.log(error)
}
})
})
then this is my function
def create(conn, %{“template” => template_params}) do
case Templates.create_template(template_params) do
{:ok, template} →
conn
|> put_flash(:info, “Template created successfully.”)
|> redirect(to: Routes.template_path(conn, :show, template))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
Marked As Solved
Laetitia
Do you really send a map with a key template? Maybe you just send the template_params rawly.
kokolegorille is right, IO.inspect is a good idea here.
But i notice that the inspect won’t never be executed. It will fail immediately for the same reason.
Try this:
def create(conn, params) do
IO.inspect(params, label: "PARAMS")
end
2
Last Post!
VincentBlackdot
Popular in Questions
I have VueJS GUIs with the project generated using Webpack.
I have Elixir modules that will need to be used by the VueJS GUIs.
I forese...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
Hi everyone,
I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar.
I p...
New
Other popular topics
I would like to know what is the best IDE for elixir development?
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
If I have a post route which an argument:
post /my_post_route/:my_param1, MyController.my_post_handler
How would get the post params ...
New
Phoenix 1.4.0 released
Phoenix 1.4 is out! This release ships with exciting new features, most notably
with HTTP2 support, improved deve...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









