Discourse as Your First Rails App

Though it is quite a crime our “recommended” dev environment is on 2.0 p0 …

1 Like

Just open another vagrant ssh session and enter those commands. Glad you got things going!

2 Likes

And Postgres 9.1 as well.

Fix your kit!

1 Like

I just used PuTTY as you suggested here :slight_smile:

So here’s a very stupid question…
The article got me to the point where I have a running Rails server on a VM, serving me the Discourse site… which is great.
But I was kind of surprised that an article that seems to suggest it gets you started writing a RoR app, stops at installing the environment and an example app…

So… What now?

How do I start working on the files? Especially since I had to follow the advise from one commenter above to run the site from an aliased local directory, rather than the shared folder.

So do I just load the repository files into any Ruby-capable editor, and then re-synch the changed files to the local folder on the VM?

And so what should I do now?
As a newbie I still don’t know anything about ruby or rails, consequently I have no idea what to look at now or where to start…

Any advise?

Installing GitHub behind a proxy gave me some errors. The solution is here:

(Internet Explorer incredibly worked fine)

  1. Is there OAuth sign-in test howto in development mode?
  2. Is there SSO overriding avatar test howto in development mode?

OAuth should work just fine like a production system. Google for certain allows for any localhost callback URL.

SSO testing will be harder, as you’ll need to set up another local web server to serve as the source of authority.

Are the instructions in the first post still up-to-date? How about the Vagrant image itself? I’ve installed VirtualBox, Vagrant, and the Discourse repository. After SSH’ing into Vagrant and CD’ing into the Vagrant directory, I can’t bundle install due to a missing gemfile. First time using a VM, so I may indeed be doing something rather silly.

Windows 7 x64
VirtualBox 4.3.20
Vagrant 1.7.2

Vagrant was updated recently, are you still having issues?

I’ve done all the steps, and it is running. But how can I login as admin ? There is already an admin account, but I don’t know the password.

Edit: Nevermind, this guide worked for me on osx, and showed me how to create an admin account.

To get my vagrant box running on osx and avoid the nfs issue, I changed the vagrant file:

-  config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", :nfs => nfs_setting
+  config.vm.synced_folder ".", "/vagrant"

But when I start the app in my vagrant box and try to access localhost:4000 my app hangs with the following output:

 (4,3,2,5,6,7,8,9,10,11,1,12,14)) AND (NOT ( pinned_globally AND  pinned_at IS NOT NULL  ))  ORDER BY topics.bumped_at DESC LIMIT 30
D, [2015-03-19T18:51:20.066104 #5462] DEBUG -- :   User Load (1.5ms)  SELECT "users"."id", "users"."email", "users"."username", "users"."uploaded_avatar_id" FROM "users"  WHERE "users"."id" IN (24, 7, 23, 19, 22, 2, 20, 22, 11, 14, 20, 9, 20, 12, 11)
I, [2015-03-19T18:51:20.142212 #5462]  INFO -- :   Rendered list/list.erb within layouts/application (18.7ms)
I, [2015-03-19T18:51:20.151204 #5462]  INFO -- :   Rendered layouts/_head.html.erb (0.6ms)
I, [2015-03-19T18:51:20.161305 #5462]  INFO -- :   Rendered common/_special_font_face.html.erb (7.6ms)
D, [2015-03-19T18:51:20.177408 #5462] DEBUG -- :   ColorScheme Load (2.3ms)  SELECT  "color_schemes".* FROM "color_schemes"  WHERE "color_schemes"."versioned_id" IS NULL AND "color_schemes"."enabled" = 't' LIMIT 1
D, [2015-03-19T18:51:20.181779 #5462] DEBUG -- :    (1.5ms)  SELECT  "categories"."updated_at" FROM "categories"   ORDER BY updated_at desc LIMIT 1
D, [2015-03-19T18:51:20.188617 #5462] DEBUG -- :    (1.4ms)  SELECT "site_customizations"."stylesheet_baked" FROM "site_customizations"  WHERE "site_customizations"."enabled" = 't'  ORDER BY "site_customizations"."name" ASC
I, [2015-03-19T18:51:20.192962 #5462]  INFO -- :   Rendered common/_discourse_stylesheet.html.erb (28.3ms)
D, [2015-03-19T18:51:22.644547 #5462] DEBUG -- :   CACHE (0.1ms)  SELECT "site_customizations".* FROM "site_customizations"  WHERE "site_customizations"."enabled" = 't'  ORDER BY "site_customizations"."name" ASC
I, [2015-03-19T18:51:22.653375 #5462]  INFO -- :   Rendered application/_header.html.erb (1.1ms)
D, [2015-03-19T18:51:22.656411 #5462] DEBUG -- :   CACHE (0.0ms)  SELECT "site_customizations".* FROM "site_customizations"  WHERE "site_customizations"."enabled" = 't'  ORDER BY "site_customizations"."name" ASC
I, [2015-03-19T18:51:22.668399 #5462]  INFO -- :   Rendered common/_discourse_javascript.html.erb (7.0ms)
D, [2015-03-19T18:51:22.671681 #5462] DEBUG -- :   CACHE (0.0ms)  SELECT "site_customizations".* FROM "site_customizations"  WHERE "site_customizations"."enabled" = 't'  ORDER BY "site_customizations"."name" ASC
I, [2015-03-19T18:51:22.676435 #5462]  INFO -- : Completed 200 OK in 2944ms (Views: 2549.3ms | ActiveRecord: 65.9ms)

Any idea whats wrong here?

That looks all normal. Try opening your browser’s Network debugger, likely it’s taking a while to download all of the various .js files. (They’re unbundled in development.)

Hi guys, I’ve been looking through the install docs and catch a divergence in the first one about vagrant’s default memory:

The discourse-as-your-first-rails-app states in step 1 - 3: The VM image we set up defaults to 1 GB of memory…

Increase the VM memory. The VM image we set up defaults to 1 GB of memory, which makes it friendly to run on 4 GB machines. But this is the practical minimum — performance will be a lot better if you can ramp the VM memory up to 2 GB or even 4 GB. To do so, change your system’s DISCOURSE_VM_MEM environment variable to the desired amount of memory.

But the updated Vagrantfile has:

# This setting gives the VM 1024MB of RAM instead of the default 384.
v.customize ["modifyvm", :id, "--memory", [ENV['DISCOURSE_VM_MEM'].to_i, 2048].max]

Looks like the default now is 2Gb! Just a typo, but is good to keep the docs up to date. :smile:
Regards

2 Likes

Actually I commit that to the repo by mistake!

https://github.com/discourse/discourse/pull/3377

Either it needs to be changed back or the documentation needs to be changed. Sorry :flushed:

Maybe you can submit a PR to fix it?

1 Like

Did it PR-3446 after testing the VM still boot with 1024MB :ok_hand:

2 Likes

I just set up Discourse with Vagrant like the post says. I was getting empty responses

I fix it with running a server like so

bundle exec rails s -b 0.0.0.0
3 Likes

I hope my question isn’t silly in some way but I’m having trouble following this how-to. When I attempt bundle exec rake db:migrate, I get this error:

rake aborted!
NameError: uninitialized constant SiteSettings::DbProvider::RailsMultisite
/vagrant/lib/site_settings/db_provider.rb:52:in `current_site'
/vagrant/lib/site_setting_extension.rb:44:in `current'
/vagrant/lib/site_setting_extension.rb:96:in `block in setting'
/vagrant/lib/site_setting_extension.rb:93:in `synchronize'
/vagrant/lib/site_setting_extension.rb:93:in `setting'
/vagrant/lib/site_setting_extension.rb:151:in `client_setting'
/vagrant/app/models/site_setting.rb:18:in `block in load_settings'
/vagrant/lib/site_settings/yaml_loader.rb:29:in `block (2 levels) in load'
/vagrant/lib/site_settings/yaml_loader.rb:20:in `each'
/vagrant/lib/site_settings/yaml_loader.rb:20:in `block in load'
/vagrant/lib/site_settings/yaml_loader.rb:19:in `each_key'
/vagrant/lib/site_settings/yaml_loader.rb:19:in `load'
/vagrant/app/models/site_setting.rb:16:in `load_settings'
/vagrant/app/models/site_setting.rb:25:in `<class:SiteSetting>'
/vagrant/app/models/site_setting.rb:4:in `<top (required)>'
/vagrant/config/initializers/04-message_bus.rb:39:in `<top (required)>'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:652:in `block in load_config_initializer'
/var/lib/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/notifications.rb:166:in `instrument'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:651:in `load_config_initializer'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:615:in `each'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:615:in `block in <class:Engine>'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `instance_exec'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `run'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:55:in `block in run_initializers'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:44:in `each'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:44:in `tsort_each_child'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:54:in `run_initializers'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/application.rb:352:in `initialize!'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/railtie.rb:194:in `public_send'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/railtie.rb:194:in `method_missing'
/vagrant/config/environment.rb:5:in `<top (required)>'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/application.rb:328:in `require_environment!'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/application.rb:457:in `block in run_tasks_blocks'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

Can anyone help me?

Let me guess, Windows 10 ?

I installed my localhost Discourse around a year and a half ago. At that time I had Windows 7 Home Premium

I followed “Discourse as Your First Rails App” as best as I could.
Installed VirtualBox
Installed Vagrant
Installed GitHub
Downloaded Discourse

I can’t say everything has gone swimmingly since, but it worked well enough for getting familiar with Discourse and testing plugins

- UNTIL - I upgraded to Windows 10 this last weekend. Now I get

Windows PowerShell
Copyright (C) 2015 Microsoft Corporation. All rights reserved.

C:\VirtualBox\discourse [master +0 ~1 -0]> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set network interfaces...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["hostonlyif", "create"]

Stderr: 0%...
Progress state: E_FAIL
VBoxManage.exe: error: Failed to create the host-only adapter
VBoxManage.exe: error: Code E_FAIL (0x80004005) - Unspecified error (extended info not available)
VBoxManage.exe: error: Context: "int __cdecl handleCreate(struct HandlerArg *,int,int *)" at line 66 of file VBoxManageHostonly.cpp

C:\VirtualBox\discourse [master +0 ~1 -0]>

Not the exact same problem you’re having, but I am wondering if the ~2 1/2 year old instructions are still applicable or if I might need t upgrade

GitHub The Last Free Monad (3.0.6.4) 2bb6864
VirtualBox 4.3.30 r 10 16 10
vagrant 1.7.4