我想在我的angularjs控制器中做出承诺.我从Angularjs Doc中获取了示例并将其粘贴到我的控制器中.当我尝试运行代码时,控制台会打印:
Error: $q is not defined
Run Code Online (Sandbox Code Playgroud)
为什么会发生此错误,如何解决?
我试图谷歌这个问题,但大多数问题都围绕着比我更具体的问题.
一(德国)指导告诉我的承诺已经在实施的角度js和没有必要添加任何东西给它.
编辑:
这是我的控制器:
app.controller("ArgumentationController", [
'$scope', '$resource',
function($scope, $resource) {
Run Code Online (Sandbox Code Playgroud)
编辑2:评论员建议注入$ q.我这样做了:
app.controller("ArgumentationController", [
'$scope', '$resource', '$q',
function($scope, $resource, $q) {
Run Code Online (Sandbox Code Playgroud)
现在,错误不会发生.
我将TinyMCE编辑器添加到我的 Rails 应用程序中。
初始化时,可以向 TinyMCE 编辑器添加一系列选项,例如:
tinymce.init({
selector: ".tinymce-textarea",
plugins: 'advlist autolink lists link image charmap preview anchor pagebreak code table',
menubar: true
})
Run Code Online (Sandbox Code Playgroud)
如果我省略“工具栏”选项,我就可以使用样式选择按钮,如下面的 GIF 所示。
但是,当我添加“工具栏”选项时,样式选择按钮没有显示。
tinymce.init({
selector: ".tinymce-textarea",
plugins: 'advlist autolink lists link image charmap preview anchor pagebreak code table',
menubar: true,
toolbar: " styleselect | h1 h2 h3 | undo redo | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist | code styleselect table"
})
Run Code Online (Sandbox Code Playgroud)
在下面的 GIF 中,您可以看到当我为工具栏添加选项时,样式选择按钮不再存在。
为什么样式选择按钮没有显示在 Tinymce 的工具栏菜单中?
ruby …
我在Ruby on Rails网站上需要一张可拖动的图片,并且除图片没有显示之外,其他所有东西都工作正常。
这是图片的代码及其属性:
<img id="drag1" src="/images/img_logo.gif" draggable="true" ondragstart="drag(event)" width="336" height="69">
Run Code Online (Sandbox Code Playgroud)
如果我这样写,图片就会显示出来:
<%= image_tag("img_logo.gif") %>
Run Code Online (Sandbox Code Playgroud)
我的问题:我需要在上方代码中插入什么,以便我的图片(img_logo.gif)出现?
图片本身位于:/app/assets/images/img_logo.gif
编写此代码的文件是html.erb文件。
我还没有安装回形针或imagemagick之类的宝石。
编辑:感谢Meagar和Vic,这将起作用:
可以这样:
<%= image_tag('img_logo.gif', draggable: "true", id: "drag1") %>
Run Code Online (Sandbox Code Playgroud)
或这个:
<img id="drag1" src="<%= asset_path('img_logo.gif') %>" draggable="true" ondragstart="drag(event)" width="336" height="69">
Run Code Online (Sandbox Code Playgroud) 我在我的 Ruby on Rails 项目中使用了 devise,并且用户有一个 admin-attribute:
架构.rb:
create_table "users", force: :cascade do |t|
.
t.boolean "admin", default: false
end
Run Code Online (Sandbox Code Playgroud)
我希望管理员用户可以编辑其他用户。我不是第一个问这个问题的人,但所有给出的答案都缺乏明确的说明:
但我不明白我需要做什么:它"devise_for :users, :path_prefix => 'my'"在路线中提到,但我的路线中没有。然后,它提到,我需要如何删除 params 哈希的密码密钥,但我的 users_controller 为空。不再提供更多说明。
但我不完全明白,需要做什么:我明白了,我需要添加devise_for :users, :path_prefix => 'd'到我的路由中,但海报还谈到了自己构建表单和控制器,以及隔离用户控制器。我不明白,他是什么意思。
在这个中,海报使用了 cancan,而且他的用户控制器中似乎确实有一个管理类,而我没有:
class Admin::UsersController < ApplicationController
def index
@users = User.all
end
end
Run Code Online (Sandbox Code Playgroud)
再一次,我不知道海报是如何到达那里的,他做了什么。
是否有分步指南,让管理员用户编辑其他用户配置文件?
你可以在这里访问我的代码:https : //github.com/Metaphysiker/philosophica
提前致谢!
我在rails 4项目上有一个ruby,我的config/secrets.yml看起来像这样:
development:
secret_key_base: verylongnumber
postgres: 'mypassword'
Run Code Online (Sandbox Code Playgroud)
我的config/database.yml
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
host: localhost
username: myusername
password: 'mypassword' # <-- Problem here
Run Code Online (Sandbox Code Playgroud)
我需要在config/database.yml中输入密码才能从secrets.yml获取密码?
我试过了:
password: <%= ENV['postgres'] %>
password: <%= ENV["postgres"] %>
password: <%= ENV[postgres] %>
password: ENV['postgres']
password: ENV["postgres"]
password: ENV[postgres]
Run Code Online (Sandbox Code Playgroud)
但这些解决方案都没有奏效.我哪里做错了?提前致谢!