JavaScript Required.
We're sorry, but Pega7 doesn't work without JavaScript enabled. Please enable and refresh.
<p>To set up a new Rails app on a shared ASO account:</p> <ol> <li> <p>Create a new Rails app via SSH<br /> <em><strong>Note:</strong> if you don't have SSH access you need to fill out a support ticket with us to gain access.</em></p> </li> <li> <p>Move into your home directory (if you just logged in, you are already there):</p> <pre> cd ~ </pre> </li> <li> <p>Create the directory that holds your Rails application</p> <p><em><strong>Note:</strong> MyApp can be changed to whatever you would like, but whatever you choose needs to stay the same wherever you type MyApp.</em></p> <pre> rails new myapp rails new -h (to see all rails commands) </pre> </li> <li> <p>Link your Rails application into your web directory so that you may access the Rails application on your website:</p> <pre> cd public_html ln -s ../myapp/public myapp </pre> </li> <li> <p>Let the server know about your Rails application by opening up the file located at myapp/public/.htaccess</p> <p><em><strong>Note:</strong> you can access this over FTP or by using the nano or vi commands over SSH. This file shouldn't already exist in the system. If it does, you can empty it's contents.</em></p> </li> <li> <p>Put this as the entire contents of the file:</p> <pre> RailsBaseURI /myapp </pre> </li> <li> <p>Create your needed models, controllers, and views for your application<br /> <em><strong>Note:</strong> models are the objects, which will usually be linked to a table in your database.</em></p> <p>A model can be created used the following command:</p> <pre> cd ../myapp rails generate model User </pre> <p><br /> <em><strong>Note:</strong> a controller is what moves data between the model (database) and your view.</em><br /> <br /> A controller can be created using the following code:</p> <pre> rails generate controller User</pre> <p><br /> <em><strong>Note:</strong> the view is where you will control what the user sees.</em><br /> <br /> The view can either be created manually or with help of the generator:</p> <pre> rails generate controller User list</pre> <p><br /> The above code would create the controller for the User object and it will also create the needed code for the list view.</p> </li> <li> <p>If you would like to manually create this edit the User controller file, found at app/controllers/user_controller.rb, by entering the following code within the class (after class and before end):</p> <pre> def list end </pre> </li> <li> <p>Create app/views/user/list.rhtml to allow you to view the list action at http://www.example.com/myapp/user/list (replace "example.com" with your domain)</p> </li> <li> <p>Configure your database.yml for database connections (we are using MySQL in this example):</p> <pre> vi config/database.yml <strong>development: </strong>adapter: mysql encoding: utf8 database: databasename username: username password: password hostname: servername <strong>test: </strong>adapter: mysql encoding: utf8 database: test_databasename username: username password: password hostname: servername <strong>production: </strong>adapter: mysql encoding: utf8 database: prod_databasename username: username password: password hostname: servername</pre> </li> <li> <p>Create your first model (this will also generate your migration file)</p> <pre> script/generate model User</pre> </li> <li> <p>Edit the migration for this mode</p> <pre> vi db/migrate/migrationname.rb</pre> <pre> class CreateUsers < ActiveRecord::Migration def self.up create_table "users", :force => true do |t| t.column :login, :string t.column :email, :string t.column :created_at, :datetime t.column :updated_at, :datetime end end def self.down drop_table "users" end end </pre> </li> <li> <p>Attempt to migrate your code (create the tables in the database)</p> <p>rake db:migrate<br /> </p> </li> <li> <p>Create your first controller</p> <p>rails generate controller user<br /> <br /> You can also predefine the list action. This will create the necessary view as well:<br /> <br /> rails controller user list<br /> <br /> Set the user controller and list action as your default action by first removing public/index.html and then uncommenting the map.root line in routes.rb:<br /> <br /> vi config/routes.rb</p> <p>You can have the root of your site routed with 'map.root', just remember to delete 'public/index.html'</p> </li> </ol> <p>Install the default routes as the lowest priority: map.root :controller => "user", :action => "list</p> <p>See how all your routes lay out with 'rake routes'?</p> <pre> map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format'</pre>