我有一个型号Products :: Car.我该如何翻译其属性?
我已经尝试过了:
activerecord:
models:
products:
car: "??????????"
attributes:
products:
car:
owner: "????????"
Run Code Online (Sandbox Code Playgroud)
还有这个:
activerecord:
models:
products_car: "??????????"
attributes:
products_car:
owner: "????????"
Run Code Online (Sandbox Code Playgroud)
但如果我尝试使用Products :: Car.model_name.human,它仍然会说"Car".我的其他翻译工作得很好,语言设置为:ru.
localization namespaces model ruby-on-rails internationalization
我的应用程序应呈现html,以便在用户单击ajax-link时进行回答.
我的控制器:
def create_user
@user = User.new(params)
if @user.save
status = 'success'
link = link_to_profile(@user) #it's my custom helper in Application_Helper.rb
else
status = 'error'
link = nil
end
render :json => {:status => status, :link => link}
end
Run Code Online (Sandbox Code Playgroud)
我的帮手:
def link_to_profile(user)
link = link_to(user.login, {:controller => "users", :action => "profile", :id => user.login}, :class => "profile-link")
return(image_tag("/images/users/profile.png") + " " + link)
end
Run Code Online (Sandbox Code Playgroud)
我试过这样的方法:
ApplicationController.helpers.link_to_profile(@user)
# It raises: NoMethodError (undefined method `url_for' for nil:NilClass)
Run Code Online (Sandbox Code Playgroud)
和:
class Helper
include Singleton …Run Code Online (Sandbox Code Playgroud) 我有一个用Ruby编写的TCPclient.我想在后台使用它.目前它有一个循环:
loop do
end
Run Code Online (Sandbox Code Playgroud)
所以我可以运行一个客户端,它永远有效.
有没有办法作为服务运行,并写一个pid文件,然后我将能够通过pid杀死该进程?
background ×1
controller ×1
daemon ×1
helper ×1
localization ×1
model ×1
namespaces ×1
ruby ×1
service ×1
tcpclient ×1