나는 레일을 처음 사용합니다. 라이브러리 시스템이고 Loan_fines에 액세스하려고하는 동안 새로운 레일스 프로젝트를 진행했습니다. 이상한 오류가 발생했습니다. 다음과 같이우분투의 Rails 3.2에 대한 이상한 ActiveRecord :: StatementInvalid 오류
오류는 다음과 같습니다 : - 대출 벌금 ID에 대한
class LoanFinesController < ApplicationController
# GET /loan_fines
# GET /loan_fines.json
def index
@loan_fines = LoanFine.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @loan_fines }
end
end
# GET /loan_fines/1
# GET /loan_fines/1.json
def show
@loan_fine = LoanFine.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @loan_fine }
end
end
# GET /loan_fines/new
# GET /loan_fines/new.json
def new
@loan_fine = LoanFine.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @loan_fine }
end
end
# GET /loan_fines/1/edit
def edit
@loan_fine = LoanFine.find(params[:id])
end
# POST /loan_fines
# POST /loan_fines.json
def create
@loan_fine = LoanFine.new(params[:loan_fine])
respond_to do |format|
if @loan_fine.save
format.html { redirect_to @loan_fine, notice: 'Loan fine was successfully created.' }
format.json { render json: @loan_fine, status: :created, location: @loan_fine }
else
format.html { render action: "new" }
format.json { render json: @loan_fine.errors, status: :unprocessable_entity }
end
end
end
# PUT /loan_fines/1
# PUT /loan_fines/1.json
def update
@loan_fine = LoanFine.find(params[:id])
respond_to do |format|
if @loan_fine.update_attributes(params[:loan_fine])
format.html { redirect_to @loan_fine, notice: 'Loan fine was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @loan_fine.errors, status: :unprocessable_entity }
end
end
end
# DELETE /loan_fines/1
# DELETE /loan_fines/1.json
def delete
@loan_fine = LoanFine.find(params[:id])
@loan_fine.deleted = 1
@loan_fine.save
respond_to do |format|
format.html { redirect_to loan_fines_url }
format.json { render :json => { :success => true } }
end
end
end
내 색인은 다음과 같습니다 : - -이
<h1 class="List">Listing Loan Fines</h1>
<table class="table table-bordered" >
<tr>
<th>ID</th>
<th>Category Id</th>
<th>Loan Duration</th>
<th>Book Id</th>
<th>Fine Amount</th>
<th>Fine Duration</th>
<th>Edit</th>
<th>Delete</th>
</tr>
<% @loan_fines.each do |c| %>
<tr>
<td><%= link_to c.id, {:action => 'show', :id => c.id} %> </td>
<td><%= c.category_id %> </td>
<td><%= c.loan_duration %> </td>
<td><%= c.book_id %> </td>
<td><%= c.fine_amount %> </td>
<td><%= c.fine_duration %> </td>
<td><%= link_to 'Edit', {:action => 'edit', :id => c.id} %> </td>
<td><%= link_to 'Delete', {:action => 'delete', :id => c.id},
:data => { :confirm => "Are you sure you want to delete this value?" } %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Loan fine', new_loan_fine_path %>
다음과 같이
ActiveRecord::StatementInvalid in LoanFinesController#index
PG::Error: ERROR: relation "loan_fines" does not exist
LINE 5: WHERE a.attrelid = '"loan_fines"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"loan_fines"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
내 LoanFines 컨트롤러 인 내 기록은 다음과 같습니다 : -
Started GET "/loan_fines" for 127.0.0.1 at 2013-03-29 22:36:37 -0700
Processing by LoanFinesController#index as HTML
PG::Error: ERROR: relation "loan_fines" does not exist
LINE 5: WHERE a.attrelid = '"loan_fines"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"loan_fines"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
Completed 500 Internal Server Error in 1ms
ActiveRecord::StatementInvalid (PG::Error: ERROR: relation "loan_fines" does not exist
LINE 5: WHERE a.attrelid = '"loan_fines"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"loan_fines"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
):
app/controllers/loan_fines_controller.rb:5:in `index'
Rendered /home/chiron/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/_trace.erb (5.2ms)
Rendered /home/chiron/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.0ms)
Rendered /home/chiron/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (11.3ms)
나는 이것에 익숙해 져있다. 이것의 가장 이상한 부분은 같은 코드가 Ubuntu am getting an error
을 시도하는 동안 work on windows
인 것처럼 보인다는 것이다.
아무도 도와 주실 수 없습니까?
모델을 추가해야합니다 ... –
PostgreSQL 데이터베이스에'LoanFine' 모델이 있지만'load_fines' 테이블이 없습니다. –
@muistooshort 데이터베이스에 테이블이 있습니다 – Catmandu