我正在使用VirtualBox将OS X作为主机,并在来宾VM上使用CentOS.
在OS XI创建的文件夹中myfolder,将其作为共享文件夹添加到VM,打开VM,在CentOS创建的文件夹中/home/user/myfolder键入:
sudo mount -t vboxsf myfolder /home/user/myfolder
Run Code Online (Sandbox Code Playgroud)
并有输出:
/sbin/mount.vboxsf: mounting failed with the error: No such device
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
更新:
Guest Additions 安装.
我收到错误未知属性:user_id执行current_user.stories.build
class User < ActiveRecord::Base
has_many :stories, class_name: 'Story', foreign_key: 'user_id', dependent: :destroy
...
class Story < ActiveRecord::Base
belongs_to :user, class_name: 'User', foreign_key: 'user_id'
...
Run Code Online (Sandbox Code Playgroud)
schema.rb
create_table "stories", :force => true do |t|
t.string "responsible"
t.string "descr"
t.string "state"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "users", :force => true do |t|
t.string "email"
t.string "password_digest"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "name"
end
Run Code Online (Sandbox Code Playgroud)
它不包含'user_id'字段.有任何想法吗?
我知道在go模板中我可以调用add为表达式命名的函数1 + 1.但是如何命名函数表达式2 - 1?
我有一个奇怪的问题:我在rvm的rails上安装了ruby.一切都很好,我可以创建项目..但重新启动后,当我键入"rails new"时,我有"程序'rails'目前尚未安装."
System Ubuntu 12.04
ruby -v
"1.9.3p194"
gem list
actionmailer (3.2.5)
actionpack (3.2.5)
activemodel (3.2.5)
activerecord (3.2.5)
activeresource (3.2.5)
activesupport (3.2.5)
arel (3.0.2)
builder (3.0.0)
bundler (1.1.4)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.3.3)
erubis (2.7.0)
execjs (1.4.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
jquery-rails (2.0.2)
json (1.7.3)
mail (2.4.4)
mime-types (1.18)
multi_json (1.3.6)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.5)
railties (3.2.5)
rake (0.9.2.2)
rdoc (3.12)
rubygems-bundler (1.0.2)
rvm (1.11.3.3)
sass (3.1.19)
sass-rails (3.2.5) …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,当我通过迁移添加此字段时,它是没有"名称"字段的用户模型.在我的localhost上我的注册表单工作正常,但在heroku上我有这个日志:
ActionView::Template::Error (undefined method `name' for #<User:0x0000000518fb00>):
Rendered users/new.html.haml within layouts/application (3.1ms)
5: = f.input :name, required: 'true'
6: = f.input :email, required: 'true'
3: %h1 Sign up
4: = simple_form_for @user do |f|
7: = f.input :password
8: = f.input :password_confirmation, required: 'true'
Run Code Online (Sandbox Code Playgroud)
我尝试过的:
heroku run rake db:migrate
heroku run rake db:reset
Run Code Online (Sandbox Code Playgroud)
但没有任何帮助.
我有问题.我已经安装了rvm但是当我尝试cap deploy:setup使用时:
bash: /usr/local/rvm/bin/rvm-shell: No such file or directory
command finished in 244ms
failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.3-p0' -c 'mkdir -p /srv/xxx /srv/xxx/releases /srv/xxx/shared /srv/xxx/shared/system /srv/xxx/shared/log /srv/xxx/shared/pids'" on xxxxxxxx
Run Code Online (Sandbox Code Playgroud)
我试着cd给/usr/local/rvm,但我有No such file or directory.怎么解决?
我是 Ruby on Rails 的菜鸟,我有一个愚蠢的问题:在我的 session_controller 中,我有
def create
user = User.find_by_email(params[:email])
if user && user.authenticate(params[:password])
session[:user_id] = user.id
redirect_to root_path, :notice => "Logged in!"
else
flash.now.alert = "Invalid email or password"
render "new"
end
end
Run Code Online (Sandbox Code Playgroud)
在路线中,我匹配“/signin”,至:“sessions#new”
在 new.html.haml 我有
= simple_form_for :session do |f|
= f.input :email
= f.input :password
= f.button :submit, 'Sign in!'
Run Code Online (Sandbox Code Playgroud)
当我按下“登录”按钮时,我希望将调用“创建”方法(它在我的用户模型中的工作方式),但调试显示“新”方法,并且我有“authenticity_token”而无需填写电子邮件和密码。有人能给我解释一下发生了什么事吗?我不明白什么时候调用“new”方法,然后调用其他方法。
例如,我有一个请求:
POST /api/users/1/categories/2/posts/3
Run Code Online (Sandbox Code Playgroud)
我怎样才能访问这个参数?
我试过了:
req.ParseMultipartForm(defaultMaxMemory)
req.Form.Get("id")
req.Form.Get("1")
req.Form.Get("_1")
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
关于GET的同样问题:
GET /api/users/1/categories/2/posts/3
Run Code Online (Sandbox Code Playgroud)
怎么没有命名参数?
req.URL.Query().Get(???)
Run Code Online (Sandbox Code Playgroud) 谁能解释一下这个import陈述是如何运作的?
例如,我User在myapp/app/models包中有一个类型:
package models
type User struct {
// exportod fields
}
Run Code Online (Sandbox Code Playgroud)
我Users在myapp/app/controllers包中有一个类型:
package controllers
import (
_ "myapp/app/models"
"github.com/revel/revel"
)
type Users struct {
*revel.Controller
}
func (c Users) HandleSubmit(user *User) revel.Result {
// Code here
}
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误:
undefined: User
我尝试将导入更改为以下代码:
import (
. "advorts/app/models"
"github.com/revel/revel"
)
Run Code Online (Sandbox Code Playgroud)
但得到这个错误:
undefined: "myapp/app/controllers".User
我也不明白.那么,import . "something"和之间有什么区别import "something"?如何import在我的案例中正确使用我的模型?
请检查一下这个要点并告诉我,出了什么问题?
为什么我看不到我的消息?
要点: https: //gist.github.com/cnaize/895f61b762a9f5ee074c
如果简单的话,我有两个函数:
func send(param martini.Params, r render.Render) {
Ct.Msgs <- param["msg"]
fmt.Printf("Sent: %v", param["msg"])
r.JSON(http.StatusOK, Response{"status": "ok"})
}
Run Code Online (Sandbox Code Playgroud)
及watch功能:
func watch(rw http.ResponseWriter, r render.Render) {
var msg string
ok := true
for ok {
select {
case msg, ok = <-Ct.Msgs:
rw.Write([]byte(msg))
fmt.Printf("Wrote: %v", msg)
f, ok := rw.(http.Flusher)
if ok {
f.Flush()
fmt.Println("Flushed")
} else {
r.JSON(http.StatusOK, Response{"status": "error", "descr": "CANT_FLUSH"})
return
}
}
}
r.JSON(http.StatusOK, Response{"status": "ok", "descr": "finished"})
}
Run Code Online (Sandbox Code Playgroud)
为什么它不起作用?
编辑: …
go ×4
ruby ×4
ubuntu ×2
activerecord ×1
capistrano ×1
centos ×1
flush ×1
function ×1
heroku ×1
import ×1
macos ×1
martini ×1
parameters ×1
redirect ×1
rvm ×1
simple-form ×1
templates ×1
virtualbox ×1