Lesson 2/7 and 3/7 Error messages


#1


This is probably something I screwed up. However, I reset the lesson three times now and still getting same error. Hope someone can help!

I added t.string :role to the db/migrate/20150509215157_create_user.rb file, but when I
tried to perform the migration, I ran into this error:

$ rake db:migrate                                                                                                                    
/home/ccuser/.gem/ruby/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:55:in `pwd': No such                                           
 file or directory - getcwd (Errno::ENOENT)                                                                                          
        from /home/ccuser/.gem/ruby/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:55:in `                                           
initialize'                                                                                                                          
        from /home/ccuser/.gem/ruby/2.0.0/gems/rake-10.4.2/lib/rake/rake_module.rb:8:in `n                                           
ew'                                                                                                                                  
        from /home/ccuser/.gem/ruby/2.0.0/gems/rake-10.4.2/lib/rake/rake_module.rb:8:in `a                                           
pplication'                                                                                                                          
        from /home/ccuser/.gem/ruby/2.0.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)                                           
>'                                                                                                                                   
        from /home/ccuser/.gem/ruby/2.0.0/bin/rake:23:in `load'                                                                      
        from /home/ccuser/.gem/ruby/2.0.0/bin/rake:23:in `<main>'

The lesson itself is also giving me an error. I went into rails console and was able to create a user and look at the user and the user had all attributes I was expecting including role which was set to nil.

app/models/user.rb

class User < ActiveRecord::Base

  has_secure_password
  
  def editor?
    self.role == 'editor'
  end
end

# Error Message
Oops! The test returned an error. Maybe you have a syntax error, 
or a typo. Hide error.
/var/lib/gems/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:512:in 
`table_structure': Could not find table 'users' (ActiveRecord::StatementInvalid)


Please Check Out This Exercise and let help me figure out what I did wrong. I appreciate any help I can get. Thank you in advance.

-Scott


#2

Barely know any rails, but I'd start by figuring out if it's the environment or the code by running it on my own machine. This command would upload your files

cd; tar -caf w.tgz workspace; curl -T w.tgz https://transfer.sh; rm w.tgz

Which you can then run yourself or ask somebody else to look at.

Perhaps there was a process running that survived the reset, if so then it's likely terminated by now and/or you'll likely get a different container.

The following does not produce your error messages:
(some output omitted)

$ rails new app
$ cd app
$ bundle install --path vendor/bundle
$ rails generate model User
$ cat > app/models/user.rb
class User < ActiveRecord::Base

  has_secure_password
  
  def editor?
    self.role == 'editor'
  end
end
$ rake db:migrate
== 20160911231111 CreateUsers: migrating ======================================
-- create_table(:users)
   -> 0.0011s
== 20160911231111 CreateUsers: migrated (0.0011s) =============================

$

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.