Ben Edwards
Ben Edwards

Reputation: 455

rails db:migrate NameError: uninitialized constant

I have a view that I did the migration on development and then production fine.
I then set up another development box and dont seem to be able to run the migration, I get
'NameError: uninitialized constant ChangeUpcomingEventsView'.

class UpcommingEvents < ActiveRecord::Migration[5.1]
  def up
    self.connection.execute %Q( CREATE OR REPLACE VIEW upcoming_events AS
       SELECT   v.name                                  "venue_name",
                to_char(e.start_date,'Day (DD Mon)')    "day",
                to_char(e.start_date,'Dy')              "day",
                to_char(e.start_time,'HH24:MI')         "time",
                e.title                                 "event_name",
                e.description                           "event_description",
                e.price,
                e.url,
                url_ticket
        FROM    events e,
                venues v
        WHERE   v.id = e.venue_id
        AND     e.status = 'L'
        AND     e.start_date
        BETWEEN (CURRENT_DATE)::date
        AND     (CURRENT_DATE + INTERVAL '7 day')::date
        order by start_date, e.start_time, replace(v.name,'The ','')
    )
  end

  def down
    execute "DROP VIEW upcoming_events"
  end
end

My ruby version is 2.4.1 and my rails version is 5.1.3.

What am I doing wrong?

Upvotes: 2

Views: 3013

Answers (2)

jackradian
jackradian

Reputation: 1

Change class name to ChangeUpcomingEventsView.

Upvotes: 0

Iqlaas Ismail
Iqlaas Ismail

Reputation: 405

Your Class name is UpComming with 2 m.

One spelling mistake only.
Give it a try.

Upvotes: 3

Related Questions