Doesn't work erb engine

I'm new in RoR:)

I have controller and view (/app/controllers/greeting_controller.rb
and /app/views/greeting/index.rhtml /.erb/.html.erb - doesn't match).

greeting_controller.rb source:

class GreetingController < ApplicationController
  def index
    @message = "Hello world!"
  end
end

index.rhtml source:

<html>
<head><title>test</title></head>
<body>
<p><%= @message %></p>
</body>
</html>

and html output is exact copy of index.rhtml

* i'm working on macOS 10.6.4

please help!!))

Quoting Karen Kalashyan <karenishe@gmail.com>:

I'm new in RoR:)

I have controller and view (/app/controllers/greeting_controller.rb
and /app/views/greeting/index.rhtml /.erb/.html.erb - doesn't match).

You don't say which version of Rails you are using, so I will assume 2.x. If
1.x or 3.x, ignore this reply.

greeting_controller.rb and index.rhtml look fine. But they are not following
Rails naming conventions, controller names are plural, i.e.,
greetings_controller.rb and /app/views/greetings/. index.rhtml is old style
naming, preferred current practice is index.html.erb. These two changes may
be enough to solve your problem.

I don't understand the last bit of the sentence above. Please expand what you
mean by "/.erb/.html.erb - doesn't match". Do you mean that
/app/view/greeting/index.erb and /app/view/greeting/index.html.erb are ignored
by the template engine?

HTH,
  Jeffrey

rename /app/views/greeting/index.rhtml to ...../index.html.erb

I don’t understand the last bit of the sentence above. Please expand what you

mean by “/.erb/.html.erb - doesn’t match”. Do you mean that
/app/view/greeting/index.erb and /app/view/greeting/index.html.erb are ignored
by the template engine?

Yes!

It doesn’t make sense.

I’m using 2.x version.

Now controller name is Greetings, and view file name is index.html.erb

But the problem hasn’t been solved :frowning:

I don't understand the last bit of the sentence above. Please expand what
you
mean by "/.erb/.html.erb - doesn't match". Do you mean that
/app/view/greeting/index.erb and /app/view/greeting/index.html.erb are
ignored
by the template engine?

Yes!
It doesn't make sense.
I'm using 2.x version.
Now controller name is Greetings, and view file name is index.html.erb
But the problem hasn't been solved :frowning:

Please tell us the current filenames and contents again to make sure
of what you have done. Have you removed all the old files? Rails has
a habit of loading files that you have left lying around by accident.
What exactly is the symptom now seen?

Colin

app/

controllers/

application_controller.rb

greetings_controller.rb

helpers/

application_helper.rb
greetings_helper.rb
models/
photo.rb
views/
greetings/

index.html.erb
layouts/

greetings_controller.rb:
class GreetingsController < ApplicationController

def index

	@mes = 'test'

end

end

index.html.erb

<%= @mes %>

html ouput (http://localhost:3000/greetings/ or http://localhost:3000/greetings/index/):

<%= @mes %>

Why it’s so hard?! :slight_smile:

No bug report… Nothing…

app/

controllers/

application_controller.rb

greetings_controller.rb

helpers/

application_helper.rb
greetings_helper.rb

models/

photo.rb

views/

greetings/

index.html.erb

layouts/

greetings_controller.rb:
class GreetingsController < ApplicationController
def index
@mes = 'test'
end
end
index.html.erb
<p><%= @mes %></p>
html ouput (http://localhost:3000/greetings/
or http://localhost:3000/greetings/index/):
<p><%= @mes %></p>

Why it's so hard?! :slight_smile:
No bug report.. Nothing..

Could you avoid top posting please, it makes it more difficult to
follow the thread.

What do you see in development.log?

Which version of rails are you using? You said 2.x but that covers a
lot of versions.

Colin

i’m using last version from rubyonrails.org

log:
[4;35;1mSQL (0.2ms) [0m [0mSET SQL_AUTO_IS_NULL=0 [0m

Processing GreetingsController#index (for 127.0.0.1 at 2010-07-05 12:41:42) [GET]

Rendering greetings/index

Completed in 2ms (View: 1, DB: 0) | 200 OK [http://localhost/greetings/index/]

config/routes.rb

map.connect 'greeting', :controller => 'greeting', :action => 'index'

?

I am out of ideas as to why the erb code is not being interpreted. Anyone else?

Colin

config/routes.rb
map.connect 'greeting', :controller => 'greeting', :action => 'index'

?

no :frowning:

WTF?!

may be something wrong with macos 10.6.4 and current version of RoR?

Random guess: a stray invisible character somewhere in the file.

Fred

What do you mean by "current"? 2.3.8, 3.0beta -- which is it?

Do you have a small test case you can post somewhere?

FWIW, I'm running 2.3.8 at the moment on Mac OS 10.6.4 with no
problems. Other than self-inflicted ones, of course :slight_smile:

i’m using 1.3.7

That seems unlikely - there never was a version 1.3.x of rails
(perhaps you've reported the version number of rubygems itself?)

Fred

can you dump the output you get after executing script/about in the thread.

Regards,
Amiruddin Nagri,

hm…

ruby -v

ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]

script/about

About your application’s environment

Ruby version 1.8.7 (universal-darwin10.0)

RubyGems version 1.3.7

Rack version 1.1

Rails version 2.3.8

Active Record version 2.3.8

Active Resource version 2.3.8

Action Mailer version 2.3.8

Active Support version 2.3.8

Application root /Library/WebServer/Documents/ruby_project_1

Environment development

Database adapter mysql

Database schema version 1