Discourse as Your First Rails App

I believe the instructions say to use port 4000 in your browser. Is there any reason you are not following those instructions?

So once the server is up, open up a web browser on your local workstation and navigate to http://localhost:4000

(I don’t know why the console says Thins on port 3000 but it’s not related)

Opps
I was reading my terminal, that’s why

working now, thanks :100:

Tiny little thing to mention, if you’re doing this on an OSX machine (I assume the same issues might arise in a Linux install as well): as per the suggestions, I installed the git repo on my regular HD, and the VM on my SSD. The problem is that the regular HD had a space in its name- “The Dump”, which caused the NFS commands to bomb out somewhere (I assume unescaped spaces). All I had to do was halt vagrant and rename the drive “Dump” instead, and then vagrant ran fine and I’m happily hacking away.

Very useful sandbox you’ve provided: I’m a fairly experienced developer with limited ruby experience, so it’s nice to have not only a place to explore the running system, but to also get a handle on ruby/rails in general. Whee! Into the giant slippery bathtub of doom!

3 Likes

Perhaps slightly off topic, but I just stumbled across across this EdX course being taught with Rails and thought of this post when I read:

What versions of Ruby and Rails will we use in the course? We will
make available at least 2 weeks before class a virtual machine image
with all required courseware. You can either download this image and
run it using the free VirtualBox (virtualbox.org) software on any
Intel x86-based computer, or you can deploy it on Amazon’s Elastic
Compute Cloud using instructions we will provide. In general, we’ll be
using Rails 3.1 and Ruby 1.9.2, but we will also be using many other
tools, gems, and libraries that will be preinstalled.

Visit: VM instructions to download the virtual machine and access
directions for setup.

Hi! First of all, thanks for the guide which is a great help to ROR newbies like myself.

I have followed the steps provided in the guide to a T. There are no problems with setting up the VM, installing the bundles and getting everything up and running. However, once the server is up, and I open localhost:4000, it is taking an eternity to load. Much longer than the “5 or 10 seconds” mentioned in the Discourse guide. It took upwards of 3 to 5 minutes for my first-time load. Is this expected given my system config provided below?

I’ve run the tests as mentioned in the Discourse Troubleshooting guide and all of them pass without any issues. I get zero failures. It should be noted that everything I am doing is right off the Master branch.

My system config is as follows:

CPU: Intel Core i5 760 2.8 GHz Quad Core
RAM: Transcend 12 GB RAM
Primary HDD: 128 GB SSD (This is where Windows 8.1 is installed)
Secondary HDD: 250 GB 7200 RPM HDD (This is where all my VMs are stored. Most importantly, this is where “only” my VMs are stored. Unfortunately, not an SSD at this point, working on that.)
Virtualbox version: 4.2.10
Vagrant version: 1.2.2
RAM allocated to Ubuntu VM: 4GB

This is what I get the first time I open up Discourse: LINK

And this is the second time, obviously faster: LINK

I am not sure whether I am doing something incorrectly, but I just wanted to bring this to your attention.

Have you done the steps I mentioned earlier in this topic?

Ooh. I should really put an embarrassed smiley here for not reading through all the replies thoroughly before making the post. That did improve the performance a lot. Thank you!

1 Like

I am newbie to vagrant and ROR. I have created the discourse server as specified in the guide. The page localhost:4000 is not loading in my browser(both firefox & chrome). it says “Waiting for localhost”.

At server the response code is 200 with views rendered in about 5-6 seconds. This happens multiple times. The page timeout is not happening either.
Last few lines
“Rendered list/list.erb within layouts/application (10.4ms)
Rendered common/_special_font_face.html.erb (3.2ms)
Rendered common/_discourse_stylesheet.html.erb (1016.3ms)
Rendered common/_discourse_javascript.html.erb (4689.2ms)
Completed 200 OK in 6851ms (Views: 6173.0ms | ActiveRecord: 246.3ms)”

Can someone help?

Update: I stopped the page loading in Firefox and Chrome after >5min and the page was displayed in firefox. Thereafter the other pages loaded fairly in the expected timeframe (3-4 seconds). The site is fully functional in my browser. In a seperate tab when i try to load the homepage again and stop it in less than a minute, nothing turns up.
In Chrome it was still empty page but the viewsource shows me a complete HTML page in the browser.

My VM memory is the default size. I am running everything from a single drive(by necessity). I have “/vagrant” contention, so all the reasons for slowing down will apply.

I assume it to be some file that was supposed to load from the server is not coming to the browser and hence the delay in the first time. Firefox ignores the file and loads the rest. Chrome doesn’t. Am I correct?

did you see this post above? not sure, but it may help

Before I invest in an SSD card, I would like to know if this guide is suited for me.

I have no experience with linux. I have no experience with ruby. I do know a bit of html/css/php/javascript/jquery, stuff like that. And I would like to be able to play around with the code. learn ruby a bit, and maybe even contribute to this awesome project.

Is this guide suited for me ? Even without any experience with linux ?

Yes, for setting up a development environment, this guide works great. There may be lingering performance issues on Windows though.

Following through the blog post, everything went fine until the rake db:migrate step. Here’s how I got things working.

I got this error:

[vagrant@precise32:/vagrant (master)]$ bundle exec rake db:migrate
rake aborted!
No such file or directory - /vagrant/config/redis.yml

Looking in config there are a number of *.sample files. Once I renamed the following files I was able to complete the database migration and start up the server:

[vagrant@precise32:/vagrant/config (master)]$ mv redis.yml.sample redis.yml
[vagrant@precise32:/vagrant/config (master)]$ mv database.yml.development-sample database.yml

Hope that comes in useful for someone.

1 Like

If you want to start up vagrant again, do you need to repeat the exact same steps ?

I’ve done all the steps including zogstrip steps and I get the same problem as @maikeru_horando so I did also that steps. Everything seems alright, except that I’m not able to “create a topic” or post anything. I’ve tried login in with different accounts. But it seems like the bar on the bottom just won’t show up.

I’ve deleted the machine and tried reinstalling, but I get the same problems…

Edit: It works now :slight_smile:

To start up the second time I just did the following:

vagrant up

to start vagrant

vagrant ssh

to connect to the running virtual machine

cd /vagrant

to change to the directory containing the discourse source

bundle exec rails s

to start up the rails server discourse runs on.

1 Like

On my windows 8 pc i ge this error:

Installing mysql2 (0.3.13)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-2.0.0-p0-turbo/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query()... -lmysqlclient
checking for main() in -lm... yes
checking for mysql_query()... -lmysqlclient
checking for main() in -lz... yes
checking for mysql_query()... -lmysqlclient
checking for main() in -lsocket... no
checking for mysql_query()... -lmysqlclient
checking for main() in -lnsl... yes
checking for mysql_query()... -lmysqlclient
checking for main() in -lmygcc... no
checking for mysql_query()... -lmysqlclient
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/local/rvm/rubies/ruby-2.0.0-p0-turbo/bin/ruby
        --with-mysql-config
        --without-mysql-config
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-mlib
        --without-mlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-zlib
        --without-zlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-socketlib
        --without-socketlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-nsllib
        --without-nsllib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-mygcclib
        --without-mygcclib
        --with-mysqlclientlib
        --without-mysqlclientlib


Gem files will remain installed in /usr/local/rvm/gems/ruby-2.0.0-p0-turbo/gems/mysql2-0.3.13 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.0.0-p0-turbo/gems/mysql2-0.3.13/ext/mysql2/gem_make.out

An error occurred while installing mysql2 (0.3.13), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.13'` succeeds before bundling.

MySQL libraries are either not installed or not found.

Although…I’m wondering what’s pulling in mysql2 at all, since Discourse is a Postgres-only project…

2 Likes

Hey guys,

I really love the idea behind discourse and we’d like to use it instead of the old-fashioned forums software we’re all so tired of.

I checked out the source from Git. Now, running “bundle install” results in the following error:

Fetching gem metadata from https://rubygems.org/......
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.0) 
Using i18n (0.6.9) 
Using minitest (4.7.5) 
Using multi_json (1.8.2) 
Using atomic (1.1.14) 
Using thread_safe (0.1.3) 
Using tzinfo (0.3.38) 
Using activesupport (4.0.2) 
Using builder (3.1.4) 
Using erubis (2.7.0) 
Using rack (1.5.2) 
Using rack-test (0.6.2) 
Using actionpack (4.0.2) 
Using mime-types (1.25.1) 
Using polyglot (0.3.3) 
Using treetop (1.4.15) 
Using mail (2.5.4) 
Using actionmailer (4.0.2) 
Using actionpack-action_caching (1.0.0) 
Using activemodel (4.0.2) 
Using active_model_serializers (0.8.1) 
Using activerecord-deprecated_finders (1.0.3) 
Using arel (4.0.1) 
Using activerecord (4.0.2) 
Using addressable (2.3.5) 
Using airbrake (3.1.2) 
Using annotate (2.6.0) 
Using handlebars-source (1.1.2) 
Using ember-source (1.2.0.1) 
Using execjs (2.0.2) 
Using barber (0.4.2) 
Using coderay (1.1.0) 
Using better_errors (1.0.1) 
Using debug_inspector (0.0.2) 
Using binding_of_caller (0.7.2) 
Using bundler (1.3.4) 
Using timers (1.1.0) 
Using celluloid (0.15.2) 
Using certified (0.1.1) 
Using connection_pool (1.2.0) 
Using daemons (1.1.9) 
Using diff-lcs (1.2.4) 
Using discourse_plugin (0.0.1) from source at vendor/gems/discourse_plugin 
Using email_reply_parser-discourse (0.6) 
Using ember-data-source (0.14) 
Using thor (0.18.1) 
Using railties (4.0.2) 
Using jquery-rails (3.0.4) 
Using ember-rails (0.14.1) 
Using eventmachine (1.0.3) 
Using excon (0.28.0) 
Using exifr (1.1.3) 
Using fabrication (2.8.1) 
Using fakeweb (1.3.0) 
Using multipart-post (1.2.0) 
Using faraday (0.8.8) 
Using rake-compiler (0.9.2) 
Using fast_blank (0.0.1) 
Installing fast_stack (0.1.0) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb 
creating Makefile

make
generating fast_stack-i386-mingw32.def
compiling fast_stack.c
In file included from c:/RailsInstaller/Ruby1.9.3/include/ruby-1.9.1/ruby/defines.h:223:0,
                 from c:/RailsInstaller/Ruby1.9.3/include/ruby-1.9.1/ruby/ruby.h:67,
                 from c:/RailsInstaller/Ruby1.9.3/include/ruby-1.9.1/ruby.h:32,
                 from fast_stack.c:3:
c:/RailsInstaller/Ruby1.9.3/include/ruby-1.9.1/ruby/win32.h:283:12: error: conflicting types for 'gettimeofday'
c:\railsinstaller\devkit\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/sys/time.h:39:29: note: previous declaration of 'gettimeofday' was here
In file included from c:/RailsInstaller/Ruby1.9.3/include/ruby-1.9.1/ruby/ruby.h:1381:0,
                 from c:/RailsInstaller/Ruby1.9.3/include/ruby-1.9.1/ruby.h:32,
                 from fast_stack.c:3:
c:/RailsInstaller/Ruby1.9.3/include/ruby-1.9.1/ruby/missing.h:48:8: error: redefinition of 'struct timezone'
c:\railsinstaller\devkit\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/sys/time.h:26:8: note: originally defined here
fast_stack.c: In function 'rb_profile_start':
fast_stack.c:9:22: error: storage size of 'timer' isn't known
fast_stack.c:11:34: error: 'suseconds_t' undeclared (first use in this function)
fast_stack.c:11:34: note: each undeclared identifier is reported only once for each function it appears in
fast_stack.c:11:46: error: expected ';' before '__extension__'
fast_stack.c:13:5: warning: implicit declaration of function 'setitimer'
fast_stack.c:13:15: error: 'ITIMER_REAL' undeclared (first use in this function)
fast_stack.c:9:22: warning: unused variable 'timer'
fast_stack.c: In function 'rb_profile_stop':
fast_stack.c:21:22: error: storage size of 'timer' isn't known
fast_stack.c:23:15: error: 'ITIMER_REAL' undeclared (first use in this function)
fast_stack.c:21:22: warning: unused variable 'timer'
make: *** [fast_stack.o] Error 1


Gem files will remain installed in C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/fast_stack-0.1.0 for inspection.
Results logged to C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/fast_stack-0.1.0/ext/fast_stack/gem_make.out
An error occurred while installing fast_stack (0.1.0), and Bundler cannot
continue.
Make sure that `gem install fast_stack -v '0.1.0'` succeeds before bundling.

I noticed that there’s been a fix for a similar issue at the fast_stack repository a few months ago, but I still keep getting this error. Any ideas?

It looks like you’re running Ruby on Windows. That’s not a supported development environment as not every gem we use works with windows. You should consider using a linux virtual machine for development and to deploy onto Linux.

3 Likes

Okay, set up a VM as you said, and everythings building fine now. Ruby is up and running, however, the page takes an average of 40 seconds to load. Console output shows nothing unsual (for me).

PS D:\Dev\Workspaces\discourse> vagrant ssh -c "bundle exec rails s"
ln: failed to create symbolic link `/vagrant/public/plugins/emoji': Protocol error
=> Booting Thin
=> Rails 4.0.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of
 your locale you can set I18n.enforce_available_locales = false to avoid this message.
Thin web server (v1.6.1 codename Death Proof)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop
DEPRECATION WARNING: You didn't set config.secret_key_base. Read the upgrade documentation to learn more about this new
config option. (called from require at script/rails:6)


Started GET "/" for 10.0.2.2 at 2013-12-19 16:46:36 -0500
Processing by ListController#latest as HTML
  ←[1m←[35m (1.3ms)←[0m  SELECT "groups"."name" FROM "groups"
  ←[1m←[36mCategory Load (3.9ms)←[0m  ←[1mSELECT "categories".* FROM "categories" WHERE (NOT categories.read_restricted)
 ORDER BY "categories"."position" ASC←[0m
  ←[1m←[35mTopic Load (3.3ms)←[0m  SELECT id, title, slug FROM "topics" WHERE ("topics"."deleted_at" IS NULL) AND "topic
s"."id" IN (10, 11, 12, 13, 41, 42, 43, 44, 45, 46, 47)
  ←[1m←[36m (1.5ms)←[0m  ←[1mSELECT "categories"."id" FROM "categories" WHERE (1=0)←[0m
  ←[1m←[35mPostActionType Load (2.5ms)←[0m  SELECT "post_action_types".* FROM "post_action_types" ORDER BY position asc
  ←[1m←[36mSiteContent Load (1.9ms)←[0m  ←[1mSELECT content FROM "site_contents" WHERE "site_contents"."content_type" =
'top' ORDER BY "site_contents"."content_type" ASC LIMIT 1←[0m
  ←[1m←[35mSiteContent Load (1.7ms)←[0m  SELECT content FROM "site_contents" WHERE "site_contents"."content_type" = 'bot
tom' ORDER BY "site_contents"."content_type" ASC LIMIT 1

I’ve assigned 4098 MB RAM to VirtualBox, which itself is installed on an SSD. Both the VM and the local Git repo are on another hard drive (not an SSD, though). Do you have any hints how to speed up page loading further?

EDIT: Nevermind, just realized that there are several performance tips above, I’ll try those first and come back later.

Highly recommend that you install Ubuntu in VirtualBox and try our Docker images.