我想用一些额外的宝石来定制我的开发环境.我正在使用带有rails 3.0.x的bundler.我在本地系统中有那些额外的宝石,我不想将它们添加到我的Gemfile中.我怎样才能通过bundler并在我的控制台中使用bundle exec打开这些宝石?
我为特定操作定义了路由并创建了一个链接.我也创建了相应的视图,但没有代码定义控制器动作方法.单击链接时仍会显示视图.也就是说,在没有实际存在的动作的情况下渲染视图.
有什么解释吗?
是否有必要在控制器中提及控制器中的私有方法helper_methods?喜欢
class PostsController < ApplicationController
helper_method :check_something
def new
check_something
@post = Post.new
end
def show
@post = Post.find(params[:id])
end
private
def check_something
redirect_to(root_path) and return if something
end
end
Run Code Online (Sandbox Code Playgroud)
声明: helper_method :check_something要求吗?如果是这样的话?
当我从控制器调用私有方法时,操作方法是params私有helper方法还是方法?
Ruby不支持递增变量variable++.我看到这种行为:
2 ++ 4
Run Code Online (Sandbox Code Playgroud)
给6.事实上,+两个变量之间的任何数字都被视为一个单一的+.ruby如何管理?而且由于红宝石这样做,它可以被视为++操作员不可用的原因吗?