我正在尝试使用以下代码在我的页面上生成链接
%h2= link_to '{{ label }}', product_path('{{ id }}'.html_safe)
Run Code Online (Sandbox Code Playgroud)
这实际上是一个较大的HTML块的一部分,它将作为一个javascript模板,我稍后将解析使用Underscore.js以填充{{ id }}和{{ label }}占位符.所以我想让rails输出一些东西给我的HTML
/ products/{{id}}
然而,它一直在逃避空间和小礼物,并给予我
<a href="/products/%7B%7B%20id%20%7D%7D">{{ label }}</a>
Run Code Online (Sandbox Code Playgroud)
所以url_helper正在逃避我的字符串,即使我不想要它.我怎么能强迫它不这样做?
我试过了
%h2= link_to '{{ label }}', product_path('{{ id }}'.html_safe)
%h2= link_to '{{ label }}', product_path(raw '{{ id }}')
%h2= link_to '{{ label }}', raw(product_path('{{ id }}'))
Run Code Online (Sandbox Code Playgroud)
和
%h2=raw( link_to '{{ label }}', product_path('{{ id }}'.html_safe))
Run Code Online (Sandbox Code Playgroud)
但它们都不起作用
编辑:
使用它的另一种方法是使用rails console,
include ActionController::UrlWriter
ruby-1.9.2-p0 :010 > product_path '{{ id }}'.html_safe
=> "/products/%7B%7B%20id%20%7D%7D"
Run Code Online (Sandbox Code Playgroud)
任何帮助表示感谢...谢谢
谢谢
我正在学习VIM,并希望尝试破解一些VIM插件,但似乎无法找到学习脚本语言的任何资源.它似乎被称为VIMscript,但我发现在Google上几乎没有任何用处.有没有人有任何建议学习如何从头开发VIM插件?
谢谢
我试图用自制软件在OS X 10.6.8上安装rabbitmq,但它失败了......所以我试着擦掉我的Homebrew安装并重新安装.但是,现在我尝试安装的任何内容都会收到相同的失败消息.我也没有看到任何调试方法.谁看过这个吗?我也安装了XCode 3.2.6.在这里,我尝试安装git
brew install git -v
Run Code Online (Sandbox Code Playgroud)
产量
make -C templates DESTDIR='' install
: no custom templates yet
install -d -m 755 '/usr/local/Cellar/git/1.7.7.1/share/git-core/templates'
readlink: illegal option -- f
usage: readlink [-n] [file ...]
usage: dirname path
ls: /install_*: No such file or directory
(cd blt && tar cf - .) | \
(cd '/usr/local/Cellar/git/1.7.7.1/share/git-core/templates' && umask 022 && tar xof -)
/bin/sh: line 0: cd: /usr/local/Cellar/git/1.7.7.1/share/git-core/templates: No such file or directory
make[1]: *** [install] Error 1
make: *** [install] …Run Code Online (Sandbox Code Playgroud) 我正在开发一个Rails应用程序,设计师正在分别设计原始HTML页面.很难让他的环境设置为直接使用应用程序,所以我希望能够以某种方式"存储"我的应用程序生成的所有页面的HTML,到某个目录,我可以通过该版本给设计师.
有谁知道一个宝石或耙子任务,可以帮助我做这样的事情?
我也愿意与不熟悉rails的设计师并行工作.
谢谢
编辑
我想我的问题的一个修正案是,是否有人也知道如何生成页面链接列表以供给wget,而不是通过手工完成它们
编辑2
只是大声思考......在应用程序中生成每个可能的页面,您需要调用每个控制器中的每个动作.所以我需要一个程序来查找我的所有app/gems /插件中存在哪些控制器,然后找到它们中的所有公共方法..或者......也许我可以使用列表中可路由的操作的路线
然后,您可能希望过滤掉不呈现html的操作
然后,您可能希望过滤掉破坏性操作(除非此程序在测试环境中运行,并且每次都重建系统).
然后,由于许多操作取决于提供的参数,您需要控制将哪些参数发送到每个操作...
然后你还必须能够发送会话cookie才能登录
还有什么..
有没有办法以编程方式设置vim文件类型,所以不要这样做:
au BufNewFile,BufRead *.dump set filetype=sql
Run Code Online (Sandbox Code Playgroud)
我可以做这样的事情
let g:temp_file_type = 'sql'
au BufNewFile,BufRead *.dump set filetype= g:temp_file_type
Run Code Online (Sandbox Code Playgroud) 为什么YAML.load返回错误的值?
ruby-1.9.2-p0 :006 > a = YAML.load('merchant_id: 014213245611111')
=> {"merchant_id"=>843333440073}
ruby-1.9.2-p0 :007 > a["merchant_id"]
=> 843333440073
Run Code Online (Sandbox Code Playgroud)
我在ruby 1.9.2-p0,rvm,ubuntu10.10,64bit.
我有两个数字存储在varibles,a和b中,我想看看这两个数字的比例是否为整数或不是python.但是,当我尝试
result = a./b
Run Code Online (Sandbox Code Playgroud)
它给了我一个
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)
但是,如果我说
result = a/b
Run Code Online (Sandbox Code Playgroud)
它会截断小数部分.如何获得完整的数字来测试完整性?
我打算用
if (not isinstance(result, (int, long))):
then do something for non-integer numbers..
Run Code Online (Sandbox Code Playgroud)
谢谢,我正在使用python 2.7.1
出于某种原因,我的项目搞砸了,现在我每次尝试运行都会抛出错误bundle install.通过重新排序我的宝石,我设法解决了一些错误Gemfile,但现在我得到了这个:
Bundler could not find compatible versions for gem "faraday":
In Gemfile:
omniauth depends on
faraday (~> 0.7.3)
twitter depends on
faraday (0.6.1)
Run Code Online (Sandbox Code Playgroud)
我认为使用bundler应该删除依赖wtf's?我假设这个消息意味着两个宝石需要2个不同版本的faraday..?
我怎么能解决这个问题呢?为什么不安装这两个版本,每个gem加载它想要的版本?
我喜欢这方面的帮助!
谢谢
Gemfile.lock:https://gist.github.com/1061722
的Gemfile:
# Edit this Gemfile to bundle your application's dependencies.
source 'http://rubygems.org'
gem 'rails', '3.0.9' #, :git => 'git://github.com/rails/rails.git'
gem "haml-rails"
gem "jquery-rails"
# Gem to abstract away the dplication common in standard restful controllers
gem 'inherited_resources'
# Allows us to …Run Code Online (Sandbox Code Playgroud) 我有一个域名example.com由一个AWS账户购买和拥有,并且其Route53服务中存在托管区域.
我想将apex和任何子域的所有DNS查询委派给第二个AWS账户,而不将域名转移到第二个AWS账户.
这可能吗?如果是这样,我该怎么办?
为什么以下ruby代码返回""而不是"Code is empty"?
code = ""
case code
when code.empty?
"Code is empty"
else
code
end
Run Code Online (Sandbox Code Playgroud) 我试图禁用我在我的应用程序中没有使用的rails部分,例如ActionMailer.我的application.rb,我做了以下更改
require "action_controller/railtie"
require "action_mailer/railtie"
#require 'rails/all'
Run Code Online (Sandbox Code Playgroud)
我的应用程序工作正常.现在,当我去评论"require"action_mailer/railtie"'行时,我收到以下错误.我没有安装任何邮件,所以发生了什么?
谢谢
=> Booting WEBrick
=> Rails 3.0.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/railtie/configuration.rb:77:in `method_missing': undefined method `action_mailer' for #<Rails::Application::Configuration:0x00000002c337f8> (NoMethodError)
from /home/test/shipped/deluxe/deluxe/config/environments/development.rb:18:in `block in <top (required)>'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/application.rb:47:in `class_eval'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/application.rb:47:in `configure'
from /home/test/shipped/deluxe/deluxe/config/environments/development.rb:1:in `<top (required)>'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `block in require'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `block in load_dependency'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
from /home/test/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
from …Run Code Online (Sandbox Code Playgroud) 我有一个应用程序,我的测试通过rails 3.0.6.我已经确定了一个git提交,唯一的变化是我将Gemfile中的rails版本从3.0.6更改为3.0.8,并且我运行了bundle update.在那之后,我的测试失败了......足够公平.但是,当我尝试降级到3.0.6时,我的测试仍然失败..这表明某些东西不适用于降级.我尝试以下操作
change version in Gemfile from 3.0.8 to 3.0.8
run bundle update
rm Gemfile.lock
rm -rf vendor/bundle/*
bundle install
Run Code Online (Sandbox Code Playgroud)
在这之后,我的测试仍然失败.我在这里不知所措..我是否因为降级过程而遗漏了一些东西?
编辑:
当我在Gemfile中更改rails版本时,我有一个错误的假设,即没有其他任何改变.通过运行
bundle update
Run Code Online (Sandbox Code Playgroud)
我的Gemfile.lock最终将我的一些宝石更新为更新的github版本,而这些新的提交破坏了一些东西.当我在我的Gemfile中引用工作提交时,一切都会再次起作用
gem "carrierwave", :git => 'https://github.com/jnicklas/carrierwave.git', :ref => "0d2e9ee8706074059cb78f2f85232caf17327952"
Run Code Online (Sandbox Code Playgroud)