Docker for Windowsならたぶんここでブラウザに「http://localhost:8080」でnginxが表示されると思うのですが、今回はDockerToolboxを利用しているのでもう一手間要ります。 VirtualBoxに「default」という仮想マシンが作成されていると思いますが(環境によっては変わる?)、このVM上でDockerが動いています。
$ mix ecto.gen.repo -r OurCustom.Repo
* creating lib/our_custom
* creating lib/our_custom/repo.ex
* updating config/config.exs
Don't forget to add your new repo to your supervision tree
(typically in lib/hello.ex):
worker(OurCustom.Repo, [])
...
children = [
# Start the Ecto repository
Hello.Repo,
# Start the endpoint when the application starts
HelloWeb.Endpoint,
# Starts a worker by calling: Hello.Worker.start_link(arg)
# {Hello.Worker, arg},
# Here you could define other workers and supervisors as children
OurCustom.Repo
]
...
defmoduleMix.Tasks.Hello.GreetingdouseMix.Task@shortdoc"Sends a greeting to us from Hello Phoenix"@moduledoc""" This is where we would put any long form documentation or doctests. """defrun(_args) doMix.shell.info("Greetings from the Hello Phoenix Application!")
end# We can define other functions as needed here.end
mix local.phx # Updates the Phoenix project generator locally
mix phx # Prints Phoenix help information
mix phx.digest # Digests and compresses static files
mix phx.digest.clean # Removes old versions of static assets.
mix phx.gen.cert # Generates a self-signed certificate for HTTPS testing
mix phx.gen.channel # Generates a Phoenix channel
mix phx.gen.context # Generates a context with functions around an Ecto schema
mix phx.gen.embedded # Generates an embedded Ecto schema file
mix phx.gen.html # Generates controller, views, and context for an HTML resource
mix phx.gen.json # Generates controller, views, and context for a JSON resource
mix phx.gen.presence # Generates a Presence tracker
mix phx.gen.schema # Generates an Ecto schema and migration file
mix phx.gen.secret # Generates a secret
mix phx.new # Creates a new Phoenix application
mix phx.new.ecto # Creates a new Ecto project within an umbrella project
mix phx.new.web # Creates a new Phoenix web project within an umbrella project
mix phx.routes # Prints all routes
mix phx.server # Starts applications and their servers
Add the resource to your browser scope in lib/hello_web/router.ex:
resources "/posts", PostController
Remember to update your repository by running migrations:
$ mix ecto.migrate
Add the resource to your :api scope in lib/hello_web/router.ex:
resources "/posts", PostController, except: [:new, :edit]
Remember to update your repository by running migrations:
$ mix ecto.migrate
Add your new module to your supervision tree,
in lib/hello/application.ex:
children = [
...
HelloWeb.Presence
]
You're all set! See the Phoenix.Presence docs for more details:
http://hexdocs.pm/phoenix/Phoenix.Presence.html
Request: GET /cms/pages
** (exit) an exception was raised:
** (Protocol.UndefinedError) protocol Ecto.Queryable not implemented for Hello.Repo, the
given module does not provide a schema. This protocol is implemented for: Atom, BitString, Ecto.Query, Ecto.SubQuery, Tuple
(ecto) lib/ecto/queryable.ex:40: Ecto.Queryable.Atom.to_query/1
(ecto) lib/ecto/repo/queryable.ex:14: Ecto.Repo.Queryable.all/3
(hello) lib/hello/cms.ex:23: Hello.CMS.list_pages/0
...