我有一个模型存储零售店的详细信息.
在Outlet模型中,我有一个前置过滤器
after_save :is_outlet_verified
def is_outlet_verified
if self.latitude.present? && self.longitude.present?
self.update_attributes(:is_verified => true)
else
self.update_attributes(:is_verified => false)
end
end
Run Code Online (Sandbox Code Playgroud)
如果出口地理编码,我想设置is_verified字段true.但是,当成功执行is_outlet_verified时,它会触发after_save回调,这会再次触发is_outlet_verified.
我在Postgresql中有一个名为monthly_trips的表.有一行值为id = 3&al = 107.415.我的问题是当我尝试访问rails中"al"列的值时.使用Rails控制台和下面的代码我得到的结果是6154.426156397738.我不知道是什么产生了这个更大的数字(确切地说是57.295779513倍).任何帮助将不胜感激!如果您需要更多信息,请与我们联系.
trip = MonthlyTrip.find(3)
result = trip.al
Run Code Online (Sandbox Code Playgroud)
monthly_trip.rb
class MonthlyTrip < ActiveRecord::Base
attr_accessible :al, :month, :vehicle_id, :year
belongs_to :vehicle
end
Run Code Online (Sandbox Code Playgroud)
psql输出(选择id,来自monthly_trips,其中id = 3;)
id | al
----+---------
3 | 107.415
(1 row)
Run Code Online (Sandbox Code Playgroud)
psql输出(\ d monthly_trips)
Table "public.monthly_trips"
Column | Type | Modifiers
------------+-----------------------------+------------------------------------------------------------
id | integer | not null default nextval('monthly_trips_id_seq'::regclass)
vehicle_id | integer |
year | integer |
month | integer |
al | numeric(9,3) |
ak | numeric(9,3) |
az | numeric(9,3) |
ar …Run Code Online (Sandbox Code Playgroud) 我正在配置我的apache服务器,并且必须多次访问我的conf文件的最后几行.是否有任何Vim命令可以帮助我吗?
我正在使用带有rails 3.0.9的ruby 1.9.2.
每当我尝试执行rake db:seed时,它会抛出以下错误:
rake aborted!
uninitialized constant EmployeeCategory
Run Code Online (Sandbox Code Playgroud)
我已禁用线程安全并在config/application.rb文件中启用了"dependency_loading".
config.threadsafe! unless $rails_rake_task
config.dependency_loading = true
Run Code Online (Sandbox Code Playgroud)
但它仍然无法正常工作.
这是seed.rb文件的内容
StudentCategory.destroy_all
StudentCategory.create([
{:name=>"OBC",:is_deleted=>false},
{:name=>"General",:is_deleted=>false}
])
EmployeeCategory.create([
{:name => 'Management',:prefix => 'MGMT',:status => true},
{:name => 'Teaching',:prefix => 'TCR',:status => true},
{:name => 'Fedena Admin',:prefix => 'Admin',:status => true},
{:name => 'Non-Teaching',:prefix => 'NTCR',:status => true}
])
EmployeePosition.create([
{:name => 'Principal',:employee_category_id => 2,:status => true},
{:name => 'Jr.Teacher',:employee_category_id => 3,:status => true},
{:name => 'Clerk',:employee_category_id => 4,:status => true}
])
Run Code Online (Sandbox Code Playgroud) 我有一个为rails 2编写的应用程序.我正在升级到rails 3.我的应用程序的大多数功能都有效,但它不会呈现任何布局.我正在使用默认的'erb'引擎.
我在我的控制器中明确地调用了一个布局,但它甚至不能渲染最简单的布局
layout 'application'
Run Code Online (Sandbox Code Playgroud)
它不会抛出任何错误.
当我创建一个新项目并尝试在其中呈现布局时,它完美地工作.
main()
{
char a[20];
int b;
printf("\n enter your name");
a[20]=getchar();
printf("\n enter your password");
scanf("%d",&b);
if (a=="ilangeeran")
{
printf("\n login successful");
}
}
Run Code Online (Sandbox Code Playgroud)
这是示例程序,在编译此堆栈时发生粉碎错误如何解决此错误?