There are quite a few of these question in stackoverflow none of which have been able to help me. I am launching an amazon ec2 using rails and postgresql. I have it launched but keep getting the following error (I have done everything including rake db:migrate even everything here https://stackoverflow.com/a/19804714/7039895):
ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "campaigns" does not exist
LINE 8: WHERE a.attrelid = '"campaigns"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
(SELECT c.collname FROM pg_collation c, pg_type t
WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation),
col_description(a.attrelid, a.attnum) AS comment
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"campaigns"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
):
app/models/campaign.rb:15:in `block in <class:Campaign>'
app/controllers/creatives_controller.rb:30:in `storage'
app/controllers/creatives_controller.rb:5:in `index'
Here are the files from the application trace:
campaign.rb(model)
class Campaign < ApplicationRecord
acts_as_taggable # Alias for acts_as_taggable_on :tags
extend FriendlyId
friendly_id :title, use: :slugged
belongs_to :author
has_attached_file :image, styles: { large: "600X600", medium: "300x300>", thumb: "150x150#" }, default_url: "/images/:style/missing.png"
validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/
PER_PAGE = 3
scope :most_recent, -> {order(published_at: :desc)}
scope :published, -> { where(published: true) }
scope :recent_paginated, -> (page) { most_recent.paginate(page: page, per_page: PER_PAGE) }
scope :with_tag, -> (tag) { tagged_with(tag) if tag.present? }
scope :list_for, -> (page, tag) do
recent_paginated(page).with_tag(tag)
end
def display_day_published
if published_at.present?
"Published #{published_at.strftime('%-b %-d, %Y')}"
else
"Not published yet."
end
end
def publish
update(published: true, published_at: Time.now)
end
def unpublish
update(published: false, published_at: nil)
end
end
creatives_controller.rb (has both index and storage)
class CreativesController < ApplicationController
layout "creative"
def index
@campaigns = storage.list_for(params[:page], params[:tag])
@campaigned = Campaign.order("created_at DESC").limit(6)
@recent = Campaign.order("created_at DESC").limit(3)
end
# GET /posts/1
# GET /posts/1.json
def show
@campaign = storage.friendly.find(params[:id])
@gallery = storage.friendly.find(params[:id])
end
def gallery
@galleries = storage.list_for(params[:page], params[:tag])
@galleried = Gallery.order("created_at DESC")
@current = Gallery.order("created_at DESC")
end
private
def storage
Campaign.published
Gallery.published
end
end
When I run this locally it works fine. It is when I run it in my amazon ec2 instance that it keeps giving me this error. Any help would be greatly appreciated.
Also, here is the code in the index.html.erb file:
<!-- Portfolio Box -->
<ul class="list-unstyled row portfolio-box">
<% @recent.each do |campaign| %>
<li class="col-sm-4">
<%= link_to campaign.image.url, :class => "thumbnail fancybox", data: { rel: "gallery" }, title: campaign.title do %>
<%= image_tag campaign.image, :class => "full-width img-responsive" %>
<span class="rounded-x portfolio-box-in">
<i class="fa fa-search-plus"></i>
</span>
<% end %>
<div class="headline-left margin-bottom-10"><h3 class="headline-brd"><%= campaign.title %></h3></div>
<small class="project-tag"><i class="fa fa-tags"></i><%= raw campaign.tags.map{ |t| link_to t.name, campaigns_path(tag: t.name)}.join(', ') %></small>
<p><%= truncate(campaign.description, length: 130) %> </p>
</li>
<%end%>
</ul>
<!-- End Portfolio Box -->