Ruby rails

44 views
Skip to first unread message

Morad

unread,
Sep 24, 2014, 12:18:49 PM9/24/14
to rubyonra...@googlegroups.com
I installed Ruby on Rails 1.9.3 version on windows . I built a simple hello world program , the issue is that when I build it in sublime text 2 I get this error :"Uninitialized constant ApplicationController ( nameerror) " and I get the same error when run this program in the command line . My application_controller.rb look like this :

class ApplicationController < ActionController::Base

end

I installed the gems but I still get this error . I downloaded ruby rails to a mac and having the same issue.

The program :

class HelloworldsController < ApplicationController
def hi
puts "Hello world"
end
end


Any thoughts pleas ?

Frederick Cheung

unread,
Sep 24, 2014, 12:56:43 PM9/24/14
to rubyonra...@googlegroups.com


On Wednesday, September 24, 2014 5:18:49 PM UTC+1, Morad wrote:

The program :

class HelloworldsController < ApplicationController
  def hi
    puts "Hello world"
  end
end


Any thoughts pleas ?


sublime text's build action just runs the current ruby file if my memory is correct. You need to run the rails server (bin/rails s) in order to use your app.

Fred 

Jason Fleetwood-Boldt

unread,
Sep 24, 2014, 12:58:25 PM9/24/14
to rubyonra...@googlegroups.com
what exactly are you typing when you are "run this program on the command line"

did you originally do rails new on the command line to create new rails app?

Morad

unread,
Sep 24, 2014, 1:40:21 PM9/24/14
to rubyonra...@googlegroups.com
Yes I did create the new project through the command prompt, then generated a controller for it ( Helloworlds) . I went into the directory where the project is and started the rail server , tested it and it comes up on the browser.
While in the folder where the project is, issued command : ruby helloworlds_conteoller.rb ,then I would get that error . Basically I am expecting to see the output "hello world " when I run it in the command prompt and on sublime but I don't see it.
It sounds like something with the application controller but not sure what is

Morad

Jason Fleetwood-Boldt

unread,
Sep 24, 2014, 1:49:09 PM9/24/14
to rubyonra...@googlegroups.com


Who told you to run ruby helloworlds_conteoller.rb and why would you expect that output from executing that as a ruby script?

In short, that's just not how Rails is built. Your webserver starts up the entire Rails app -- including loading all associated files and dependencies -- when you run rails server. (which is sounds like you already are successfully able to do?)

Running any individual file with the ruby command isn't how a Rails app works. 
Reply all
Reply to author
Forward
0 new messages