Forum: Ruby on Rails Executing ruby on rail program through address bar

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Anil V. (Guest)
on 2006-02-13 10:23
I Want to run my ruby on rail application through address bar.
i.e like: http://localhost/rail_program/first.rhtml.

when i trying this it only executes html part but not executing rail

Here is the code:

<title>eruby example</title>
<%(1..10).each do|i|%>
  <li>number <%=i%></li>
<h1>Environment variables</h1>
<%ENV.keys.sort.each do |key|%>

After executing this it not executes code within <%  %> this tags.
What is the problem? Help me.

Thank you.
Gael P. (Guest)
on 2006-02-13 12:05
(Received via mailing list)
That would be because you dont call the views (RHTML files) directly
from the URL, you call a controller action which will then "execute"
the view and parse the RHTML file for ruby code.

In you case you need to create a controller (if you dont have this
already), create an action called "first" which doesn't have to do
anything but it will then render the file called first.rhtml and show
the environment variables as you want to do.

Since what you asking is very basic Rails, I strongly suggest you
start by doing one of the Rails tutorials located here:

This will explain you the concept of MVC which you seem to have problem

This topic is locked and can not be replied to.