1

I have just installed Rails on window. I want to Show a message in view page by routing in routes.rb but message is not displayed. My rails version is 3.2.21 and ruby is 1.9.3p551 I have made a controller from command prompt rails generate controller welcome index

welcome_controller

class WelcomeController < ApplicationController
  def index

  end
end

routes.rb is

ProjectApp::Application.routes.draw do
  get "welcome/index"
  root to: 'welcome/index'
end

i have added root to: 'welcome/index'

and view template index.html.erb

<h1>`Hello Rails!`</h1>

When i go through url[http://localhost:3000/index] it should show Hello Rails as output but it is showing welcome board only I have followed steps from http://guides.rubyonrails.org/getting_started.html

0

4 Answers 4

2

Your root url is localhost:3000 instead localhost:3000/index

Sign up to request clarification or add additional context in comments.

1 Comment

At localhost:3000 it dosenot show "Hello Rails " as output
1

As Prashant4020 said, you need to set up a view in app/views/welcome/index.html.erb

Your routes.rb should be something like this.

root 'welcome#index'
get 'welcome#index'

1 Comment

i did same but i have not got message/output
0

Add view to show customize message

views/welcome/index.html.erb

Welcome to Ruby on Rails
<%= here your code goes %>

Comments

0

For anyone looking to solve this problem . You need to install the latest version of node js (64 bit msi installer)and add it to the environment variable path(normally installer will do that for you in windows). it should fix it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.