我有这个功能
def start(data, opts \\ [pages: 17, depth: 3]) do
maxPages = opts[:pages]
maxDepth = opts[:depth]
IO.puts maxPages
IO.puts maxDepth
end
Run Code Online (Sandbox Code Playgroud)
当我这样做时,Program.start("data", pages: 8)我希望它打印8,3但它只打印8
我正在尝试将凤凰应用程序连接到MS SQL.在网上浏览后,我遇到了几个名为mssql_ecto&mssqlex的适配器.
我按照自述文件中的说明将它们添加到项目中,安装了odbc并检查了数据库是否在线,但我现在收到以下错误..
[error] Mssqlex.Protocol (#PID<0.13069.0>) failed to connect: ** (Mssqlex.Error) odbc_not_started
Run Code Online (Sandbox Code Playgroud)
我的应用程序配置如下..
config :my_app, MyApp.Repo,
adapter: MssqlEcto,
username: "<my_username>",
password: "<my_password>",
database: "test",
hostname: "<my_server>.database.windows.net",
pool_size: 10
Run Code Online (Sandbox Code Playgroud)
我的环境如下..
mssql_ecto repo中已经存在一个问题,我已经尝试了那里的建议,但它仍然无效.
如果有人设法将他们的phoenix/elixir应用程序连接到macOS上的MSSQL并且可以提供一些指令,那将非常感激(即使它以与我的方法完全不同的方式完成).
附注:在具有相同数据库的节点中尝试并且能够连接并查询数据库.
我正在使用Ruby 1.9.3并使用以下内容
puts SecureRandom.uuid
Run Code Online (Sandbox Code Playgroud)
但是我收到了错误
uninitialized constant SecureRandom
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题?
我有以下测试:
it 'create action: a user replies to a post for the first time' do
login_as user
# ActionMailer goes up by two because a user who created a topic has an accompanying post.
# One email for post creation, another for post replies.
assert_difference(['Post.count', 'ActionMailer::Base.deliveries.size'], 2) do
post :create, topic_id: topic.id, post: { body: 'Creating a post for the first time.' }
end
email = ActionMailer::Base.deliveries
email.first.to.must_equal [user.email]
email.subject.must_equal 'Post successfully created'
must_redirect_to topic_path(topic.id)
email.last.to.must_equal [user.email]
email.subject.must_equal 'Post reply …Run Code Online (Sandbox Code Playgroud) 我有这样的结构:
map = %{"a" => "foo",
"b" => [%{"b1" => "bar",
"b2" => "baz"}]}
Run Code Online (Sandbox Code Playgroud)
我想要的是:
map.b[0].b1
Run Code Online (Sandbox Code Playgroud)
获得它的最简单方法是什么?
有没有办法使用它kernerl.get_in/2
如果我尝试:
url = "https://www.economist.com/news/finance-and-economics/21727073-economists-struggle-work-out-how-much-free-economy-comes-cost"
{:ok, %HTTPoison.Response{status_code: 200, body: body}} = HTTPoison.get(url)
IO.binwrite body
Run Code Online (Sandbox Code Playgroud)
我在控制台中看到乱码文本(而不是html).但如果我在网页上查看源代码,我会在那里看到HTML.我究竟做错了什么?
PS:它与js http客户端(axios.js)工作正常,不知道为什么它不适用于httpoison