MarkUs Blog

MarkUs Developers Blog About Their Project

Archive for the ‘ruby’ tag

Introducing MarkUs 1.0-alpha!

without comments

The team is pleased to announce MarkUs 1.0-alpha! This release is tagged as « alpha » in order to allow for further testing and feedback, and all input is welcome. This release may be used in production.

MarkUs 1.0-alpha contains many fixes and some features:

  • We are now using Rails 3.0
  • We fully support for Ruby 1.9.x
  • Changed PDF conversion to Ghostscript for faster conversion
  • We introduced a new REST API
  • Users now have the ability to import/export assignments settings
  • Improvements have been made to section management
  • Tests no longer use fixtures

For a list of all fixed issues, refer to: https://github.com/MarkUsProject/Markus/issues?milestone=8&state=closed Furthermore, the change log can be found at: https://github.com/MarkUsProject/Markus/blob/master/Changelog.

Go to http://www.markusproject.org to download it!

We suggest not updating from previous instances, as due to the significant number of changes introduced to the application, data loss is possible.

Thanks to all the contributors who made this release possible. Keep up the good work!

Written by Benjamin Vialle

September 11th, 2013 at 1:09 pm

Posted in Releases

Tagged with , , , ,

Pay Attention to Little Things

with one comment

On testing:

If you ever tried running your tests and find yourself getting the error:

your_controller_test.rb:3:in `require': no such file to load -- test_helper (LoadError)
from your_controller_test.rb:3

it’s probably because the generated require call, require test_helper is not being properly recognized.  Instead of the default require 'test_helper', replace it with:

require File.dirname(__FILE__) + '/../test_helper'

If you’re doing functional testing, make sure that the controller being tested is also required (e.g. add the line require 'your_controller' on top).  Be sure that you also have installed the package libtest-unit-ruby (if using Linux), before testing.

Also, thanks to Jeff Balogh, make sure that you append test_ on all your test cases to make sure that they actually run (I know it’s obvious, but it’s nice to be reminded once in a while).

On database constraints:

If you want to enforce foreign key constraints, remember to create the required indexes first.  ActiveRecord Migration supports this using add_index.  This only applies if the column being referred to is not a primary key, if it is then there’s no need to create the index. Once this is set, you can now enforce foreign keys using ActiveRecord Migrations by implementing this.

On implementing sessions:

By default, the rails session handler stores session information on a file in the server.  This can cause scalability issues in the long run if file space runs out or when using multiple servers.  Thus, it’s recommended to use :active_record_store instead. To do this make sure that you do the following:

  • execute rake db:sessions:create to add a create table migration for sessions
  • execute rake db:migrate to apply the new schema
  • change session store to active session store by adding this line to config/environment.rb:

config.action_controller.session_store = :active_record_store

  • Make sure that you comment out or add this line to your ApplicationController:

protect_from_forgery :secret => <32_hex_digit_secret_key>

Here are also some helpful links regarding sessions and implementing it:

Written by Geofrey

July 29th, 2008 at 4:01 pm

Getting Started with Ruby on Rails

with 2 comments

Update: March 13, 2009

I’ve tried installing rails again from scratch, from a newly installed Ubuntu 8.10 and I got a “no ruby-full package” error when I tried to execute the install command sudo apt-get install ruby-full rubygems build-essential

If this happens, you can enable external package repositories by going to System -> Administration -> Software Sources.  Then you can go to Third-Party Software tab and select both sources (‘http://archive.canonical.com/ubuntu intrepid’ as of Ubuntu 8.10) and do a sudo apt-get update after on the command line. Once update is done, installing ruby-full package should now work.

———-

Here, I outline the steps I took to get started with Ruby on Rails development on Ubuntu 8.04

1.  Install ruby

To install ruby (1.8.6) and rubygems, simply type:

sudo apt-get install ruby-full rubygems build-essential

2.  Update gem

When installing rails, make sure that you let gems manage it rather than apt-get, otherwise, “gem and apt-get will start fighting like Spock and Captain Kirk in Amok Time.”  Thus, we need to make sure rubygems is updated using the command sudo gem update (for gems 0.9.4)

Now, you might or might not encounter this but when I did this on Ubuntu 8.04, I got the following error:

Updating RubyGems...
Bulk updating Gem source index for: http://gems.rubyforge.org
Attempting remote update of rubygems-update
ERROR:  While executing gem ... (Gem::GemNotFoundException)
Could not find rubygems-update (> 0) in any repository

Asking the all-knowing Google lead me to this fix.  You apparently need to remove the local source_cache file found in the GEM PATH.  You can get this path by running the command gem env, giving you this result:

$ gem env
RubyGems Environment:
- VERSION: 0.9.4 (0.9.4)
- INSTALLATION DIRECTORY: /var/lib/gems/1.8
- GEM PATH:
- /var/lib/gems/1.8
- REMOTE SOURCES:
- http://gems.rubyforge.org

Once you get your GEM PATH (in my case /var/lib/gems/1.8), then you need to remove the local cache by typing:

sudo rm -rf /var/lib/gems/1.8/source_cache

and continue to update gem.

3. Install rails

Now that you have gem updated, you can then confidently install rails and its dependencies by typing:

sudo gem install rails --include-dependencies

Make sure that you also add the gem bin path to your path. If you’re using bash, then add the following line to your .bashrc, replacing <GEM_PATH> with your gem path found by typing gem env (don’t forget to restart terminal):

export PATH=$PATH:<GEM_PATH>/bin

Verify installation by typing, rails -v and get the following (or similar) response:
Rails 2.1.0

4. Install a Database

Since I already have a MySQL server, I wanted to work with it instead of the default SQLite database for Rails.  This means installing the MySQL driver for rails and typing the command:

sudo apt-get install libmysql-ruby mysql-server

You can leave out the mysql-server if you already have the MySQL server installed.

5. Install a Ruby on Rails server

Reading some of the posts, I found that there are two most popular servers to use for RoR apps: Mongrel and Webrick.  Webrick I believe comes with the rails installation, but there’s huge evidence that Mongrel might be better than Webrick.  Using the steps found here, I installed Mongrel on Ubuntu by typing:

sudo gem install mongrel --include-dependencies

You might be given options to select versions.  In my case, I just selected the latest version of mongrel (1.1.5) and fastthread (1.0.1) for ruby.

6. Create sample application

To make sure everything works, we can create a sample rails application.  Start by typing rails cookbook -d mysql if you’re using MySQL, otherwise leave the -d flag out to use SQLite instead.  The database configuration assumes that you have a MySQL user called root, with the password disabled.  If this is not the case, then you might need to edit the config file cookbook/config/database.yml and make appropriate changes under development. To make sure the database also works, we need to create a sample application that uses our database. To do this, just type in console under the cookbook directory:

ruby script/generate scaffold recipe title:string description:text category:string

mysql -u root --password=<your_password> -e "CREATE DATABASE cookbook_development"

rake db:migrate

Once that’s done, just execute mongrel_rails start under the cookbook directory, fire up your browser to http://localhost:3000/recipes (note that it’s plural) and you should see your cookbook web application staring back at you.

Note: If you get a CGI::Session::CookieStore::TamperedWithCookie error when hitting the recipes page, just hit browser refresh and that should be fixed (not sure why it does that sometimes).

7. Find a good Ruby on Rails IDE (no, this is not optional)

Now the hard part of all this is getting settled into a familiar development environment.  There are some good discussions out there on what people use as RoR IDEs.  Since I don’t have a week to throw away learning emacs, I’ve decided to start with something familiar, Eclipse.  The only decent Eclipse-based IDE out there is RadRails, but installing the standalone verion, I found that it was too alpha for me at this stage (crashes frequently, unresponsive, and can’t find my rails installation).  So I’m settling right now with the Rails plug-in for NetBeans and so far it’s been good for me, except for the occasional GUI lag that I’m getting. I’ve also heard good things about jEdit, but without the debugger support, it’s not technically an IDE for me.

Written by Geofrey

July 17th, 2008 at 4:32 pm

Posted in OLM on Rails

Tagged with , , , ,