我有以下迁移文件 db\migrate\20100905201547_create_blocks.rb
如何专门回滚该迁移文件?
在我做了brew更新和brew升级之后,我的postgres遇到了一些问题.我试图卸载postgres并重新安装,但它也没有用.
这是错误消息.(当我尝试执行rake db:migrate时,我也收到此错误消息)
$ psql
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
Mac版:山狮.
自制版:0.9.3
postgres版本:psql(PostgreSQL)9.2.1
这就是我所做的.
12:30 ~/D/works$ brew uninstall postgresql
Uninstalling /usr/local/Cellar/postgresql/9.2.1...
12:31 ~/D/works$ brew uninstall postgresql
Uninstalling /usr/local/Cellar/postgresql/9.1.4...
12:31 ~/D/works$ psql --version
bash: /usr/local/bin/psql: No such file or directory
12:33 ~/D/works$ brew install postgresql
==> Downloading http://ftp.postgresql.org/pub/source/v9.2.1/postgresql-9.2.1.tar.bz2
Already downloaded: /Library/Caches/Homebrew/postgresql-9.2.1.tar.bz2
......
......
==> Summary
/usr/local/Cellar/postgresql/9.2.1: 2814 files, 38M, built in …Run Code Online (Sandbox Code Playgroud) 这是一个两部分问题:
当您不知道模态的确切高度时,如何将模态垂直放置在中心?
是否有可能让模态居中并且在模态体中有溢出:auto,但仅当模态超过屏幕高度时?
我试过用这个:
.modal-dialog {
height: 80% !important;
padding-top:10%;
}
.modal-content {
height: 100% !important;
overflow:visible;
}
.modal-body {
height: 80%;
overflow: auto;
}
Run Code Online (Sandbox Code Playgroud)
当内容比垂直屏幕尺寸大得多时,这给了我所需的结果,但对于小模态内容,它几乎无法使用.
当我意识到你应该在视图中使用帮助器时,我需要一个帮助器在我的控制器中,因为我正在构建一个JSON对象来返回.
它有点像这样:
def xxxxx
@comments = Array.new
@c_comments.each do |comment|
@comments << {
:id => comment.id,
:content => html_format(comment.content)
}
end
render :json => @comments
end
Run Code Online (Sandbox Code Playgroud)
我怎样才能访问我的html_format助手?
有没有办法可以在Rails应用程序中获得所有模型的集合?
基本上,我可以这样做: -
Models.each do |model|
puts model.class.name
end
Run Code Online (Sandbox Code Playgroud) 我创建了一个使用随时随地宝石的应用程序.宝石创造了cron工作.我让它在本地工作,但似乎无法让它在heroku雪松上工作.执行此操作的命令是什么?
运行:
heroku run whenever --update-crontab job1
Run Code Online (Sandbox Code Playgroud)
不起作用
如何实现以下目标:我想更改.each循环中管道字符之间引用的数组元素的值.
这是我想要做的一个例子,但目前没有工作:
x = %w(hello there world)
x.each { |element|
if(element == "hello") {
element = "hi" # change "hello" to "hi"
}
}
puts x # output: [hi there world]
Run Code Online (Sandbox Code Playgroud)
很难找到如此普遍的东西.
我有这个问题
activerecord:
notices:
messages:
success:
create: "Something was created"
models:
user:
success:
create: "Thanks for registration"
I18n.t("activerecord.notices.models.user.success.create")
# => "Thanks for registration"
I18n.t("activerecord.notices.models.book.success.create")
# => "translation missing: de, activerecord, notices, models, book, success, create"
Run Code Online (Sandbox Code Playgroud)
我不知道为什么书模型没有得到后备按摩.我已经定了config.i18n.fallbacks = true.我正在使用Rails 3
fallback ruby-on-rails internationalization ruby-on-rails-3 rails-i18n
任何方式只能为某些文本强制翻译为特定语言.就像是:
t("my.text",:fr)
Run Code Online (Sandbox Code Playgroud)
原因是我希望用户能够更改其内容的语言而不是网站界面.谢谢!
ruby ×3
arrays ×2
rails-i18n ×2
activerecord ×1
center ×1
collections ×1
cron ×1
css ×1
database ×1
fallback ×1
heroku ×1
homebrew ×1
localization ×1
macos ×1
modal-dialog ×1
model ×1
postgresql ×1
rollback ×1
schema ×1
whenever ×1