Stupid newbie question

Yes, Im new to Ruby. COming from PHP/Java world. I DON’T want to learn
ruby, sigh.
Anyway I got a project that is done in ruby and it need some
modifications sometimes.

So until now, dont know how, I managed fixing a few things on that
application.
Sometimes was about setting a page to show more fields than before. Or
maybe block a page redirecting it to an access denied page.

But now things are gotting more serious and bigger modifications are
needed. I think I can manage doing that. But working like have done
until now is VERY unefficient. Basically, Im working directly on a
test server. I NEVER managed (this is the real big problem) in
installing the app, correctly, on my local machine. Im getting mad in
trying to do it it but with no success.

Thus the problem is about succesing in making the local app working.
Explaining in details everything I guess would make most of you stop
reading this post. So I try with another strategy. Here it comes:

I am on MAC. Ruby is installed by default. I MUST use Apache as
server. So I put a virtual host poiting to /MY_PATH_RO_ROR_APP/public

When typing http://localhost/ then I see the content of the public
folder.

The APP is “empty”. Im not using things like generate or scaffolding.
Why? Well, because my thought was to just copy all the application
located on the test-server and making it work. Is that bad? I dont
know. I would prefer not to go through all ruby stuff.
If it is bad it is ok, as long as this is not the cause of the thing
that the app is not working.

What I need to do is to create a controller manually and connect it
through the route.rb.

i create a file in the app folder named product_controller.rb:

class ProductController < ApplicationController

def show
render :text => ‘abcd’
return
end

end

Now I want to map the route. How can I do this? I tried different
ways. For example:

map.resources :product

or
map.connect ‘:controller/:action/:id’

or
map.connect ‘:controller/:action/:id.:format’

or
map.connect ‘:product/:show’

Well, everytime I try then to type something in the browser. I try for
example:

localhost/product/1
localhost/product/show
localhost/product/1/show
localhost/product

Well, all the time I can see the same error in the log:

File doesnt exist.

Right now Im thinking that the url-requests are managed by apache. And
that apache doesnt understand that this is a ROR app? Is that the
problem maybe??? And does anyone know how to make apache understand
that that one is a ruby app??

On Jun 2, 11:53am, Sta C. [email protected] wrote:

File doesnt exist.

Right now Im thinking that the url-requests are managed by apache. And
that apache doesnt understand that this is a ROR app? Is that the
problem maybe??? And does anyone know how to make apache understand
that that one is a ruby app??

Out of the box apache doesn’t understand rails apps. You need to
install passenger (sudo gem install passenger) which includes an
apache module for handling rails app. The passenger site has loads of
documentation.

Fred

On Thursday, June 2, 2011 6:53:09 AM UTC-4, Sta C. wrote:

Right now Im thinking that the url-requests are managed by apache. And
that apache doesnt understand that this is a ROR app? Is that the
problem maybe??? And does anyone know how to make apache understand
that that one is a ruby app??

Yes, that’s the problem.

Unlike PHP, your Rails app needs to run as a server listening on a port.
You
can’t just point Apache to your Rails directory. You can use any number
of
servers to accomplish this (WEBrick, thin, passenger).

The simplest way to start your rails application is by running “rails
server” from within your rails application directory.

I think the current preferred setup for production environments is using
Phusion Passenger, which can run as an Apache module. Check out the
documentation here:

Sent from my iPhone

On Jun 2, 2011, at 3:53 AM, Sta C. [email protected] wrote:

But now things are gotting more serious and bigger modifications are
I am on MAC. Ruby is installed by default. I MUST use Apache as
that the app is not working.
return
or

that apache doesnt understand that this is a ROR app? Is that the
problem maybe??? And does anyone know how to make apache understand
that that one is a ruby app??

Apache alone can’t serve a Rails app. You need passenger.

Rails also comes with a webserver if u cd to the project dir and type
script/server

If you need to maintain a rails app it might be good to learn some Ruby.
Trust me there are worst things out there. Google tryruby

Above I made the guess that ur app is not rails 3. You should find what
version of rails you are using because something like routing differs.

-Noel

On 2 June 2011 11:53, Sta C. [email protected] wrote:

Yes, Im new to Ruby. COming from PHP/Java world. I DON’T want to learn
ruby, sigh.

Welcome…

I am on MAC. Ruby is installed by default. I MUST use Apache as
server. So I put a virtual host poiting to /MY_PATH_RO_ROR_APP/public

Yeah… that’s not how it’s done. What have you looked at for
configuring Apache with Rails? You’ll need Passenger or something
similar to manage the Rails app - you’re just showing the HTML at the
moment, and nothing is processing the Ruby code.

my thought was to just copy all the application
located on the test-server and making it work. Is that bad? I dont
know.

If you have an existing app, this is fine.

i create a file in the app folder named product_controller.rb:

class ProductController < ApplicationController

map.resources :product

Typically, this should be “products_controller” and
ProductsController, and your route should work (once Passenger is
serving…)

Ok guys. Thank you all.
I have been fighting with this for several days. And only while I was
writing the first post I realized that, well, Apache need to know that
one is a ror app sigh!
SO most of you reccomend passenger.
I hade a look at the doc.
The I thought it would be better to just go straight forward and
install it.
I tried on two diffferent mac os x. First on tiger and then on
leopard.
In both case the same problem. Both say
ERROR: Error installing passenger:
ERROR: Failed to build gem native extension.

Well, Im so tired of all this, so I want wait before trying to
understand whats going on. I only want one thing. Only one. I wanna
see that damned upp running on my local machine.
So, what about running the ruby server? Fine. So I run the command
gem server
Going to localhost:8808 I can see the list of all installed gems. But
of course I want to see my app. How can I see that?
OPN the test server it is enough to just type:

serverurl/portals/1

Well, I only get a 404 error.

The I was thinking: why should gem server know where the app is? I
mean, where is the root of the server when you run gem server? Does it
depend on where, in what location, it is run?
I tried to run it into the folder containing my app, but without
success.
SO the question is (I guess): where is the root folder for all the
ruby apps?

On Jun 2, 5:58pm, Hassan S. [email protected]
wrote:

Probably trivial to fix – do you have all the XCode developer stuff on
your system(s)? In any case…

Well, I guess it was not so trivial.
In short:
I have been trying to run either through passenger or webrick.
Passengers fails. I can install it, after installing macports. But
when I have to run the command for installing under apache then it
fails. I have tried to find answers but with no success.

So now Im trying to make it run under webrick. I succeded in
installing a new ruby, thanks to macports.
Now when I run ruby -version I get1.8.7

Anyway, when I trie to start the webrick server with the command:
script/rails server

Then I get the following error:

APP_PATH/config/boot.rb:1:in `require’: no such file to load –
rubygems (LoadError)

The file boot.rb contains the line

require ‘rubygems’

It seems like an enviroment issue. I have searched for this, but could
not find a solution that fit my situation.
Looks like the enviroment dont really know where to look, or it looks
in the wrong place, for the required rubygems.

Any hints folk?

RVM to the rescue I guess: Go here: https://rvm.beginrescueend.com/
install it, then go to http://rubygems.org/ and install rubygems (might
actually be installed with rvm, you need to check this).

On Jun 3, 6:25pm, Martin W. [email protected] wrote:

RVM to the rescue I guess: Go here: https://rvm.beginrescueend.com/
install it, then go tohttp://rubygems.org/and install rubygems (might
actually be installed with rvm, you need to check this).

Isnt there an easier way?
I have been installing undreded of software the latest day.
I guess it is a problem in knowing which ruby runs when I put the
command for starting the server.
Im afraid that the old ruby is the one thats selected when I try to
run the webrick server.

On Thu, Jun 2, 2011 at 8:47 AM, Sta C. [email protected]
wrote:

SO most of you reccomend passenger.

In both case the same problem. Both say
ERROR: Error installing passenger:
ERROR: Failed to build gem native extension.

Probably trivial to fix – do you have all the XCode developer stuff on
your system(s)? In any case…

Well, Im so tired of all this, so I want wait before trying to
understand whats going on. I only want one thing. Only one. I wanna
see that damned upp running on my local machine.
So, what about running the ruby server? Fine. So I run the command
gem server

gem server is strictly for viewing gem documentation, not running
apps.

Assuming a Rails 2.x app, running script/server in the root of your
application will start the built-in Webrick server.

HTH,

Hassan S. ------------------------ [email protected]

twitter: @hassan

It is ONE line copy and pasted into your shell and really the
recommended
way to use Ruby on the Mac. It does not get much simpler than this.

On Fri, Jun 3, 2011 at 9:21 AM, Sta C. [email protected]
wrote:

Passengers fails. I can install it, after installing macports. But
when I have to run the command for installing under apache then it
fails. I have tried to find answers but with no success.

Well, you certainly won’t get any answers without providing the
exact error message - “it fails” is not useful.

So now Im trying to make it run under webrick. I succeded in
installing a new ruby, thanks to macports.
Now when I run ruby -version I get1.8.7

Anyway, when I trie to start the webrick server with the command:
script/rails server

You seem to be mixing up commands between Rails 2.x and 3.x.
Which do you have installed? Or more to the point, what is the app
you’re trying to run based on?


Hassan S. ------------------------ [email protected]

twitter: @hassan

On Jun 3, 6:48pm, Martin W. [email protected] wrote:

It is ONE line copy and pasted into your shell and really the recommended
way to use Ruby on the Mac. It does not get much simpler than this.

Ok IN that case I will give it a try. Thanks.

On Fri, Jun 3, 2011 at 10:00 AM, Sta C. [email protected]
wrote:

Well If I type
rails -v (I guess this is the right way?)
then I see
Rails 1.2.6

I believe you’re doomed :slight_smile:

Seriously, this has massive pain written all over it; 1.2.6 is ancient.

If I were you, I’d find someone who knows Rails, let her/him log into
the test server you previously mentioned and clone the environment
there (and the app + database + etc.) into a Linux VM. Then install
that VM on your Mac and enjoy.

I suspect such a person could also offer some general tips to make
your Rails work more productive and enjoyable.

Good luck!

Hassan S. ------------------------ [email protected]

twitter: @hassan

On Jun 3, 6:54pm, Hassan S. [email protected]
wrote:

You seem to be mixing up commands between Rails 2.x and 3.x.
Which do you have installed? Or more to the point, what is the app
you’re trying to run based on?

Well If I type
rails -v (I guess this is the right way?)
then I see
Rails 1.2.6

Btw, the current, preferred way of getting pretty much all formulas is
Homebrew http://mxcl.github.com/homebrew/. Clean, easy, simple. Also,
I
was gonna upvote the RVM recommendation until I realized…yeah…

try:

  1. install RVM and don’t use
    1.8.7http://hugofrappier.wordpress.com/2010/01/01/rails-1-2-x-ruby-1-8-6-snow-leopard-the-missing-link/.
    Use 1.8.6.
  2. make sure your RubyGems is working

cd /path/to/rails/app/dir
ruby script/server OR rails script/server

On Jun 3, 8:29pm, Hassan S. [email protected]
wrote:

your Rails work more productive and enjoyable.

Good luck!

Oh My God…

Well I tried to do like Martin suggested, installing RVM.
Non error message when doing it.
But When trying to install gems then I get the error:
You need version >= 1.8.7

The funny thing is that I installed that version with macports. But
for some reason it doesnt become the selected one (even thought
running ruby -v show the version 1.8.7 sigh).

Now I thought I maybe can try getting the latest rails? No success.
ERROR: Error installing rails:
activesupport requires Ruby version >= 1.8.7.

Its basically the same problem. The bash doesnt understand that there
is a newer ruby.
Maybe its about going deeper and set the appropriate path? Dont really
know where to begin, sigh.

Oh, also, here’s a trip down memory
lane:

After using RVM with ruby 1.8.6, try also doing gem installs with lower
versions of the gems you’re installing.

If macports is giving u trouble, uninstall
macportshttp://guide.macports.org/chunked/installing.macports.uninstalling.html.
Install Homebrew http://mxcl.github.com/homebrew/.

If everything fails, just use a simple Ubuntu VM and go from there. You
still have options.

On 06/03/2011 10:00 AM, Sta C. wrote:

On Jun 3, 6:54 pm, Hassan S.[email protected]
wrote:

You seem to be mixing up commands between Rails 2.x and 3.x.
Which do you have installed? Or more to the point, what is the app
you’re trying to run based on?
Well If I type
rails -v (I guess this is the right way?)
then I see
Rails 1.2.6

This tells you what rails is installed on your system (at least what is
in your path). The real question is what rails version the application
is running with on the target system wherever that is. You need to run
‘rails -v’ on that system or look in config/environment.rb. Towards the
top there should be a line defining the ‘RAILS_GEM_VERSION’. This tells
you what version of rails you need to use to duplicate the present
production environment. Another possibility would be if rails were
frozen into the system (unlikely). In this case you would find rails in
the directory ‘vendor/rails’ and all of your plugins in ‘vendor/plugins’
etc. The most likely case given that this has apparently been around
for a while is that you have an app written to an old rails version.
You must duplicate that environment as a first step and get the app
running in that environment to have any chance of updating it in any
way.

Good luck
Norm