Skip to content

PGError: ERROR: relation does not exist #980

Closed
Zapotek opened this Issue Feb 14, 2012 · 3 comments

3 participants

@Zapotek
Zapotek commented Feb 14, 2012

Hi,

I keep getting the following error:

: SELECT "findings".* FROM "findings" INNER JOIN "findings_issues" ON "findings"."id" = "findings_issues"."finding_id" WHERE "findings_issues"."issue_id" = 5
Rendered /home/zapotek/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails_admin-d76bec1638f4/app/views/rails_admin/main/show.html.haml within layouts/rails_admin/application (154.8ms)
Completed 500 Internal Server Error in 294ms

ActionView::Template::Error (PGError: ERROR:  relation "findings_issues" does not exist
LINE 1: SELECT "findings".* FROM "findings" INNER JOIN "findings_iss...
                                                       ^
: SELECT "findings".* FROM "findings" INNER JOIN "findings_issues" ON "findings"."id" = "findings_issues"."finding_id" WHERE "findings_issues"."issue_id" = 5):
    1: - @model_config.show.with(:object => @object, :view => self).visible_groups.each do |fieldset|
    2:   - unless (fields = fieldset.with(:object => @object, :view => self).visible_fields).empty?
    3:     - if !(values = fields.map{ |f| v = f.value; (!v.nil? && v != '' && v != []) ? v : nil }).compact.empty? || !RailsAdmin::config.compact_show_view
    4:       .fieldset
    5:         %h4
    6:           = fieldset.label

The problem is that the table in question ("findings_issues") indeed doesn't exist nor is referenced anywhere.
The relation is as follows:

  • Issues has_and_belongs_to_many :findings
  • Finding belongs_to :issue

The error occurs when trying to show any Issue entry.

@gunn
Collaborator
gunn commented Feb 15, 2012

How do you expect to relate many findings to many issues? The has_and_belongs_to_many method uses a join table to do it and by default expects one named findings_issues. Perhaps you just want Issue to have_many :findings?

See http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html

Definately not a rails_admin problem.

@gunn gunn closed this Feb 15, 2012
@Zapotek
Zapotek commented Feb 15, 2012

Sorry I'm a bit of a Rails novice.
I'll re-check my associations, thanks for the link

@davidimoore

after attempting to install rails admin i get the following error

WHERE a.attrelid = '"admins"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"admins"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum

I dropped my database and migrated all of my files but I still get the same response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.