Translations: English
Search on Docs:
ActionItem Search:

You are here: Noosfero>Dev>Console (30 Aug 2016, UnknownUser) Edit Attach

Using the Noosfero Console

Starting the console in a Debian package installation

Just run the following command as root:


With a regular user with sudo enabled, you can just run sudo noosfero-console.

You can skip the following section and go directly to Using the console.

Starting the console in a manual installation

In a terminal, change to the directory where Noosfero is installed. For example, if noosfero is installed in /home/you/noosfero:

cd /home/you/noosfero

To start the Noosfero console run:


By default, the console starts in the development environment. If you want to access production data, use:

script/console production

Alternatively, you can run the console in development mode with the command:
rails console development

And for production, you should use:
rails console production

Using the console

The Noosfero console is the Ruby-on-Rails console. Like the irb, this console is a Ruby console, so any Ruby code will be directly executed, and the Noosfero base is pre-loaded, allowing you to create or change any data directly.

See a usage example to access data:
>> p = Person['batman']
>> p.friends.each {|f| puts }
Bat Girl

Changing data:
>> p1 = Person['batman']
>> p2 = Person['superman']
>> AddFriend.create!(:requestor => p1, :target => p2).finish

Changing object attributes require saving those objects in order to have your changes reflected in the database. Example:

>> p1 = Person['batman']
>> = ''

If the save! call does not raise an exception, then everything is ok and that change is already persisted in the database.

All the entity types are classes and you may found the object instances by its methods, like the example done with the Person. Other examples are Community, User, Environment, …

Environment.default gives you access the default environment (or the only one, if you don't created extra environments) and allows you to change the roles.
e = Environment.default = "The Cool Social Network"

Considerations about console usage on production data

  1. to start the console, make sure your shell is running under the same user as the Noosfero application servers. For example, if your applications servers run under the user "noosfero", then you must first become the user "noosfero" and then enter the console:
          $ sudo su - noosfero
          $ cd /path/to/noosfero
          $ script/console production
    (replace /path/to/noosfero with the actual path to your noosfero installation!)
  2. have in mind that you are changing production data, so be careful with what you do there!

Useful Console Usage

Add comment
You need to login to be able to comment.
Topic revision: r1 - 30 Aug 2016, UnknownUser

irc Talk with Devs Now!

Copyright © 2007-2019 by the Noosfero contributors
Colivre - Cooperativa de Tecnologias Livres