User Tools

Site Tools


ruby_on_rails

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ruby_on_rails [2021/03/15 18:27] – [Getting started] added link to port allocation page peteyboyruby_on_rails [2024/09/16 07:08] (current) – pg” hc9
Line 13: Line 13:
 ===== Getting started ===== ===== Getting started =====
  
-**Step 1:** Run "mkhomepgif you have not already done so (see the [[Building a Website on SDF]] tutorial for more information on the "mkhomepgcommand).+**Step 1:** Run mkhomepg” if you have not already done so (see the [[Building a Website on SDF]] tutorial for more information on the mkhomepg” command).
  
 **Step 2:** Use the rails command to construct the base for your new rails application: **Step 2:** Use the rails command to construct the base for your new rails application:
Line 92: Line 92:
         create  log/test.log         create  log/test.log
  
-It has become SDF policy to have the project that you want to be served under '$HOME/html/railsin actuality you can locate the rails project directory anywhere and call it what you like. The 'railsctland 'rorcommand expect the project that you want to host to be located in the afore-mentioned directory. So, if you want your server to be started when the host starts and 'railsctlto find your project then you should symlink your current project to that location, or use that location.+It has become SDF policy to have the project that you want to be served under $HOME/html/rails’ in actuality you can locate the rails project directory anywhere and call it what you like. The railsctl’ and ror’ command expect the project that you want to host to be located in the afore-mentioned directory. So, if you want your server to be started when the host starts and railsctl’ to find your project then you should symlink your current project to that location, or use that location.
  
 **step 3:** **step 3:**
Line 98: Line 98:
 Start the webrick server on your [[meta port allocation |meta allocated port]] that is equal to your //uid ((Example: Start the webrick server on your [[meta port allocation |meta allocated port]] that is equal to your //uid ((Example:
  
-  $ id -u+  $ id
   uid=<YOUR UID>(<YOUR USERNAME>) gid=500(arpa) groups=500(arpa),600(MetaARPA)   uid=<YOUR UID>(<YOUR USERNAME>) gid=500(arpa) groups=500(arpa),600(MetaARPA)
  
Line 110: Line 110:
   => Ctrl-C to shutdown server; call with --help for options   => Ctrl-C to shutdown server; call with --help for options
  
-Then point your browser at ''<nowiki>http://yourdomain:<YOUR UID></nowiki>''. You should now be looking at the default 'Welcome to Rails page'. Now you can begin to develop your rails app.+Then point your browser at ''<nowiki>http://yourdomain:<YOUR UID></nowiki>''. You should now be looking at the default Welcome to Rails page. Now you can begin to develop your rails app.
  
 ===== Hello, world of Rails! ===== ===== Hello, world of Rails! =====
Line 141: Line 141:
   end   end
  
-Now let's try calling it. Navigate to the URL ''<nowiki>http://yourdomain:<YOUR UID>/say/hello</nowiki>'' in a browser window. (Note that in the development environment we don't have any application string at the front of the path we route directly to the controller.) You'll see something that looks like an error.+Now let's try calling it. Navigate to the URL ''<nowiki>http://yourdomain:<YOUR UID>/say/hello</nowiki>'' in a browser window. (Note that in the development environment we don't have any application string at the front of the path – we route directly to the controller.) You'll see something that looks like an error.
  
 It might be annoying, but the error is perfectly reasonable (apart from the weird path). We created the controller class and the action method, but we haven't told Rails what to display. And that's where the views come in. Remember when we ran the script to create the new controller? The command added three files and a new directory to our application. That directory contains the template files for the controller's views. In our case, we created a controller named say, so the views will be in the directory app/views/say. To complete our Hello, World! application, let's create a template. By default, Rails looks for templates in a file with the same name as the action it's handling. In our case, that means we need to create a file called hello.rhtml in the directory ''app/views/say''. (Why //.rhtml//? We'll explain in a minute.) For now, let's just put some basic HTML in there. It might be annoying, but the error is perfectly reasonable (apart from the weird path). We created the controller class and the action method, but we haven't told Rails what to display. And that's where the views come in. Remember when we ran the script to create the new controller? The command added three files and a new directory to our application. That directory contains the template files for the controller's views. In our case, we created a controller named say, so the views will be in the directory app/views/say. To complete our Hello, World! application, let's create a template. By default, Rails looks for templates in a file with the same name as the action it's handling. In our case, that means we need to create a file called hello.rhtml in the directory ''app/views/say''. (Why //.rhtml//? We'll explain in a minute.) For now, let's just put some basic HTML in there.
Line 161: Line 161:
  
 There are currently two main scripts that MetaARPA members can run to manage their RoR instance. The first is //ror// which is used to toggle automatic startup of your RoR instance upon system boot. The second is //railsctl// which allows you to //start//, //stop// and //restart// your RoR instance. There are currently two main scripts that MetaARPA members can run to manage their RoR instance. The first is //ror// which is used to toggle automatic startup of your RoR instance upon system boot. The second is //railsctl// which allows you to //start//, //stop// and //restart// your RoR instance.
- 
  
 [[http://sdf.org/?tutorials/Ruby_on_Rails | Ruby on Rails]] - traditional link (using [[wp>Revision_Control_System|RCS]]) [[http://sdf.org/?tutorials/Ruby_on_Rails | Ruby on Rails]] - traditional link (using [[wp>Revision_Control_System|RCS]])
 +
ruby_on_rails.1615832842.txt.gz · Last modified: 2021/03/15 18:27 by peteyboy