parasew / instiki

a basic wiki clone so pretty and easy to set up, you’ll wonder if it’s really a wiki.
https://golem.ph.utexas.edu/wiki/instiki/show/HomePage
502 stars 111 forks source link

Rails g not working #51

Open Tamenze opened 7 years ago

Tamenze commented 7 years ago

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 commented 7 years ago

script/generate

Tamenze commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

distler commented 7 years ago

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

Tamenze commented 7 years ago

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:inrescue 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 commented 7 years ago

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 commented 7 years ago

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

distler commented 7 years ago

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