未初始化的常量…错误
|
我收到以下错误:
uninitialized constant Profile::STRING_LEN_MAX_DB
。
这是我所拥有的:
application_helper.rb
def field ( form, field_name, len = TEXT_FIELD_LEN, max_len = STRING_LEN_MAX_DB )
x = content_tag \"label\", \"#{field_name.humanize}:\", :for => field_name
y = form.text_field field_name, :size => len, :maxlength => max_len { \"#{x} #{y} <br />\"}
end
编辑视图
<% form_for :profileinfo do |fe| %>
<fieldset>
<info><%= @titlu %></info>
<%= error_messages_for \'profileinfo\' %>
<div class=\"fields\">
<%= field fe, \"first_name\" %>
<%= field fe, \"last_name\" %>
<label for=\"gender\">Sex:</label>
<%= radio_button :profileinfo, :gender, \"Male\" %> Male
<%= radio_button :profileinfo, :gender, \"Female\" %> Female
<br />
<label for=\"birth_date\">Date of birth:</label>
<%= date_select :profileinfo, :birth_date, :start_year => Profile::YEAR_FT, :end_year => Time.now.year, :include_blank => true, :order => [:month, :day, :year] %>
<br />
<%= field fe, \"ocupation\" %>
<%= field fe, \"city\" %>
<%= field fe, \"country\" %>
<%= field fe, \"postal_code\", Profile::PSTCOD_LEN %>
<%= submit_tag \"Save\", :class => \"submit\" %>
</div>
</fieldset>
<% end %>
config \\ environments.rb
# Load the rails application
require File.expand_path(\'../application\', __FILE__)
# Be sure to restart your server when you modify this file
# Initialize the rails application
IRC07::Application.initialize! do |config|
STRING_LEN_MAX_DB=255
TEXT_FIELD_LEN=15
end
在ѭ4中进行更改后,我已重新启动服务器,但仍然收到相同的错误。
没有找到相关结果
已邀请:
2 个回复
良阑纠苫
退出配置循环。 因此,您的enviroment.rb看起来像:
如果这样做不起作用,请尝试: #加载rails应用程序 需要File.expand_path(\'../ application \',FILE)
寇剩
也是application_helper中的函数text_field_for
性别和生日都可以,但是对于文本字段,我没有任何文本字段,相反,我得到了带有所有参数的html标签...像这样: