Ruby on Railsは初めてです。ライブラリ管理用の新しいプロジェクトを試みていたところ、エラーが発生しました。
uninitialized constant ActionView::CompiledTemplates::Library
book_transactions で編集を実装しようとすると、エラーが発生します。
Extracted source (around line #23):
20: <div class="control-group">
21: <%= f.label :reason_id, :class => 'control-label' %>
22: <div class="controls">
23: <%= collection_select(:book_transaction, :reason_id, LovHelper.getLov(Library::Library::USER_TYPE_LOV), :id, :lov_value) %>
24: </div>
25: </div>
26: <div class="control-group">
私の見解は次のとおりです。
<%= form_for @book_transaction, :html => { :class => 'form-horizontal' } do |f| %>
<div class="control-group">
<%= f.label :book_id, :class => 'control-label' %>
<div class="controls">
<%= collection_select(:book_transaction, :book_id, Book.all, :id, :title) %>
</div>
</div>
<div class="control-group">
<%= f.label :action_date, :class => 'control-label' %>
<div class="controls">
<%= f.datetime_select :action_date, :class => 'datetime_select' %>
</div>
</div>
<div class="control-group">
<%= f.label :num_copies, :class => 'control-label' %>
<div class="controls">
<%= f.number_field :num_copies, :class => 'number_field' %>
</div>
</div>
<div class="control-group">
<%= f.label :reason_id, :class => 'control-label' %>
<div class="controls">
<%= collection_select(:book_transaction, :reason_id, LovHelper.getLov(Library::Library::USER_TYPE_LOV), :id, :lov_value) %>
</div>
</div>
<div class="control-group">
<%= f.label :notes, :class => 'control-label' %>
<div class="controls">
<%= f.text_area(:notes, :size => '80x10', :class => 'text_field')%>
</div>
</div>
<div class="control-group">
<%= f.label :entered_by, :class => 'control-label' %>
<div class="controls">
<%= f.number_field :entered_by, :class => 'number_field' %>
</div>
</div>
<div class="form-actions">
<%= f.submit nil, :class => 'btn btn-primary' %>
<%= link_to t('.cancel', :default => t("helpers.links.cancel")),
book_transactions_path, :class => 'btn' %>
</div>
<% end %>
私のテーブルは次のとおりです:-
id serial NOT NULL,
book_id integer,
action_date timestamp without time zone,
num_copies integer,
reason_id integer,
notes character varying(255),
entered_by integer,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
deleted integer NOT NULL DEFAULT 0,
CONSTRAINT book_transactions_pkey PRIMARY KEY (id)
私のLovhelperファイルは次のとおりです:-
module LovHelper
#----------------------------------------------------------------------------
# getLov - Get a list of values for a particular LOV type
#----------------------------------------------------------------------------
def self.getLov(lov_type)
lovs = LovValue.unscoped
lovs = lovs.select('lov_values.id, lov_value')
lovs = lovs.joins(:lov_name)
lovs = lovs.where('lov_names.name = ? ', lov_type)
lovs = lovs.order('sequence asc')
lovs.all
return lovs
end
#----------------------------------------------------------------------------
# getValue - Get the value pertaining to a particular LOV Value id
#----------------------------------------------------------------------------
def self.getValue(lov_value_id)
lov = LovValue.find(:all,
:select => 'lov_value',
:conditions => ['id = ? ', lov_value_id]).first
return lov.lov_value
end
#----------------------------------------------------------------------------
# getLovNames - Get a list of LOV names
#----------------------------------------------------------------------------
def self.getLovNames
lov_names = LovName.all
return lov_names
end
end
現在、私が作業するように与えられたコードは先輩によって実装されているため、理解するのに少し問題があります.
なぜこのエラーが発生するのか、誰か説明してください。