Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails g not working #51

Open
Tamenze opened this issue Jul 10, 2017 · 9 comments
Open

Rails g not working #51

Tamenze opened this issue Jul 10, 2017 · 9 comments

Comments

@Tamenze
Copy link

Tamenze commented Jul 10, 2017

I'm not sure if this is a legitimate issue or more of a local one, but I'm trying to add a new model and new controller to the app, and having no luck. Rails generate doesn't work at all, for neither models nor controllers. Does anyone have insight as to why? I've been digging for a while now and haven't found any clues. Currently looking into how to manually create migration files for entire models as a workaround, but wanted to ask here in the meantime.

@distler
Copy link
Collaborator

distler commented Jul 10, 2017

script/generate

@Tamenze
Copy link
Author

Tamenze commented Jul 10, 2017

Hmm, doesn't seem to work. When I run script/generate model User I get back the following error message:
/Users/tamenze/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- script/../config/environment (LoadError) from /Users/tamenze/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from script/generate:2:in <main>'

Line 2 of script/generate says require File.dirname(__FILE__) + '/../config/environment'. In my script folder, I don't have a config folder, is that the issue?

@Tamenze
Copy link
Author

Tamenze commented Jul 10, 2017

Update (different errors): I found this guide with more info on the script/generate command and added the . before it to make it .script/generate, which now gets me to a different error which I'm working through.

@distler
Copy link
Collaborator

distler commented Jul 10, 2017

See this commit. Not all of the generators are working yet. (In particular, model still seems to be broken.)

@distler
Copy link
Collaborator

distler commented Jul 11, 2017

This should complete the fix. Let me know if there are further problems.

@Tamenze
Copy link
Author

Tamenze commented Jul 11, 2017

Thank you! The problem I'm encountering now is outside the scope of script/generate, but if you have any advice I'd love to hear it.

There's still an error when I run script/generate, but it's because I added an initializer to the app (I'm trying to install Google Omni Auth). The error message in the console is telling me:
/instiki/config/initializers/omniauth.rb:3:in <top (required)>': undefined method application' for Rails:Module (NoMethodError).

The relevant line in omniauth.rb: Rails.application.config.middleware.use OmniAuth::Builder do
So now I'm looking into the methods that do exist for Rails:Module to try and find an alternate way of writing it (and i'm using Rails 4.2.6. and Ruby 2.3 btw).


To be clear, this^ came after I received a different error, with pry-rails when trying to generate the model: `/Users/tamenze/.rvm/gems/ruby-2.3.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'pry-rails'. (Bundler::GemRequireError) Gem Load Error is: uninitialized constant Rails::Railtie`

@Tamenze
Copy link
Author

Tamenze commented Jul 11, 2017

Still working on this problem, commented out the OmniAuth block in omniauth.rb to see what would happen. The User model generates, but without any fieldnames when I pass them in. ie: /script/generate model User provider uid name email oauth_token oauth_expires_at:datetime creates a migration that only has:

class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.timestamps
    end
  end

  def self.down
    drop_table :users
  end
end

When I added column names and types manually in the migration file, and then migrated, table was not added to the Schema. So there's a few problems in this path of working, I'll continue digging into them this week, but just an update in case anyone else has dealt with this or has some insight that could point me in the right direction.

@Tamenze Tamenze closed this as completed Jul 11, 2017
@Tamenze Tamenze reopened this Jul 11, 2017
@Tamenze
Copy link
Author

Tamenze commented Jul 12, 2017

@distler is this built on Rails 2? Can I run it on Rails 4?

@distler
Copy link
Collaborator

distler commented Jul 12, 2017

The app is built on Rails 2. Converting to Rails 4 (or 5) would be a big task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants