Topic: Migration problem

I bought this screencast on restful rails:
http://peepcode.com/products/restful-rails

I wanted to fiddle with the code but I'm having problems migrating the database. This is the first time I've not built the database through mysql so I could be doing something wrong. 

Here's my database.yml:

development:
  adapter: mysql
  database: podcast
  username: root
  password: xxxxxx
  host: localhost
  socket:  <%=
    ['/var/run/mysqld/mysqld.sock',         
     '/tmp/mysql.sock'].select { |f| File.exist? f }.first %>

test:
  adapter: mysql
  database: podcast
  username: root
  password: xxxxxx
  host: localhost
  socket:  <%=
    ['/var/run/mysqld/mysqld.sock',         
     '/tmp/mysql.sock'].select { |f| File.exist? f }.first %>

production:
  adapter: mysql
  database: podcast
  username: root
  password: xxxxxx
  host: localhost
  socket:  <%=
    ['/var/run/mysqld/mysqld.sock',         
     '/tmp/mysql.sock'].select { |f| File.exist? f }.first %>


rake db:migrate produces this:
bob@bobbyhotep:~/rails/podcast$ rake db:migrate
(in /home/bob/rails/podcast)
rake aborted!
no such file to load -- active_resource

(See full trace by running task with --trace)


Here's my migration file:(001_create_users.rb)
class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table "users", :force => true do |t|
      t.column :name,                      :string
      t.column :login,                     :string
      t.column :email,                     :string
      t.column :crypted_password,          :string, :limit => 40
      t.column :salt,                      :string, :limit => 40
      t.column :created_at,                :datetime
      t.column :updated_at,                :datetime
      t.column :remember_token,            :string
      t.column :remember_token_expires_at, :datetime
     
      t.column :activation_code, :string, :limit => 40
      t.column :activated_at, :datetime
    end
  end

  def self.down
    drop_table "users"
  end
end


This particular migration file was generated by a plugin used in this screencast project.  I pretty much followed everything verbatim from the screencast except that I'm using mysql, not sqlite3.  I did create an empty database called podcast.

Any ideas?

Last edited by BIGtrouble77 (2007-05-12 13:06:09)

Re: Migration problem

It's looking for active_resource for some reason. Do you know if there's any mention of it in the rest of the project? Perhaps in the environment.rb config file? You may need to remove the requirement or freeze edge rails to the project so you can use active resource.

Railscasts - Free Ruby on Rails Screencasts

Re: Migration problem

I did upgrade this project to rails edge with:
rake rails:freeze:edge

If I try and run the server I get this error:

=> Booting WEBrick...
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/webrick.rb:11: warning: already initialized constant OPTIONS
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- active_resource (MissingSourceFile)
        from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from /home/bob/rails/podcast/vendor/rails/activesupport/lib/active_support/dependencies.rb:495:in `require'
        from /home/bob/rails/podcast/vendor/rails/activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in'
        from /home/bob/rails/podcast/vendor/rails/activesupport/lib/active_support/dependencies.rb:495:in `require'
        from ./script/../config/../vendor/rails/railties/lib/initializer.rb:170:in `require_frameworks'
        from ./script/../config/../vendor/rails/railties/lib/initializer.rb:170:in `each'
        from ./script/../config/../vendor/rails/railties/lib/initializer.rb:170:in `require_frameworks'
        from ./script/../config/../vendor/rails/railties/lib/initializer.rb:90:in `process'
         ... 13 levels...
        from /home/bob/rails/podcast/vendor/rails/activesupport/lib/active_support/dependencies.rb:495:in `require'
        from /home/bob/rails/podcast/vendor/rails/railties/lib/commands/server.rb:39
        from ./script/server:3:in `require'
        from ./script/server:3

So it's most definitely having an issue withactive_resource, and it is using rails in the vendor directory.  I'm assuming active_resource is a part of rails 1.2+.  Am I just missing a gem?

Last edited by BIGtrouble77 (2007-05-12 14:41:55)

Re: Migration problem

BIGtrouble77 wrote:

I'm assuming active_resource is a part of rails 1.2+.

ActiveResource isn't in 1.2.x, but I think it's in edge rails. Check your environment.rb file to make sure you aren't specifying the rails version there - comment that out if you are. This may be forcing it to not use the edge rails in the vendor directory.

BIGtrouble77 wrote:

Am I just missing a gem?

Actually they recently released ActiveResource as a separate gem you can install. I think edge rails already includes it, but it's worth a try.

Railscasts - Free Ruby on Rails Screencasts

Re: Migration problem

Ryan, thank you very much once again.  Following that link did the job.  BTW, I did have the rails version commented out so the project should be using edge rails.

Re: Migration problem

Thanks Ryan! I was having this very same problem when freezing Rails to Edge.

One question though, when I migrate or start WEBrick, I get a message about config.breakpoint_server:

*******************************************************************
* config.breakpoint_server has been deprecated and has no effect. *
*******************************************************************

(I'm on Windows by the way.)

Is this anything to be worried about? Or can I ignore it? I found the source  of the message in vendor\rails\railties\lib\initializer.rb.

# vendor\rails\railties\lib\initializer.rb
# Deprecated options:
  def breakpoint_server(_ = nil)
    $stderr.puts %(
    *******************************************************************
    * config.breakpoint_server has been deprecated and has no effect. *
    *******************************************************************
    )
  end
alias_method :breakpoint_server=, :breakpoint_server

Thanks again for the link to the ActiveResource Available as a Gem.

Chris

Re: Migration problem

I actually found the solution to this at http://dev.rubyonrails.org/browser/trun … v=7183#L56 if anyone else is interested. Just remove the 'config.breakpoint_server = true' on line 12 of environments\development.rb and the deprecated error is no longer displayed when you migrate, run  WEBrick, etc.

Chris