Help needed - No route matches [GET] "/draw/load"

Hi All,

I am new to Rails. I installed rails 3.2.13. Have Ruby ver. 1.9.2p20.
I created a very simple rails example as follows.

  1. Created rails app called “chart”
  2. Generated a controller called - “draw” that has the following lines
    of code. It has a action called “load” which has no code in it.
    class DrawController < ApplicationController
    def load
    end
    end
  3. I then navigated to following directory to create a view template of
    extension - .rhtml
    C:\rails\chart\app\views\draw\
  4. I start Webrick and hit URL - “http://localhost:3000/draw/load

I get the following error:
No route matches [GET] “/draw/load”
Try running rake routes for more information on available routes.

The above example is most basic i suppose and should work. The .rhtml
page just has plain html.

Can someone please tell me what could be the issue. I remember this
worked fine with previous rails version. Has anything changed?

Help much appreciated.

On Monday, May 20, 2013 1:26:20 PM UTC-4, Ruby-Forum.com User wrote:

def load

You need to configure the route in the config/routes.db file. In this
case,

get ‘draw#load’

mike wrote in post #1109637:

On Monday, May 20, 2013 1:26:20 PM UTC-4, Ruby-Forum.com User wrote:

def load

You need to configure the route in the config/routes.db file. In this
case,

get ‘draw#load’

Hi Mike. Thanks for response. So in this case i would need to do
addition in
Routes.rb for each controller/action.? Is there no rule that can be set
In routes.rb?

On Mon, May 20, 2013 at 12:20 PM, Rochit S. [email protected]
wrote:

So in this case i would need to do
addition in
Routes.rb for each controller/action.? Is there no rule that can be set
In routes.rb?

Recommended reading: Rails Routing from the Outside In — Ruby on Rails Guides


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

twitter: @hassan

Rochit S. wrote in post #1109638:

mike wrote in post #1109637:

On Monday, May 20, 2013 1:26:20 PM UTC-4, Ruby-Forum.com User wrote:

def load

You need to configure the route in the config/routes.db file. In this
case,

get ‘draw#load’

Hi Mike. Thanks for response. So in this case i would need to do
addition in
Routes.rb for each controller/action.? Is there no rule that can be set
In routes.rb?

Hi All,

I looked at the guide and also entered:
get ‘draw#load’
This is still not working. Can someone please send me a working example
or try similar thing themselves. I am really stuck on this.

thanks

On Tue, May 21, 2013 at 12:01 AM, Rochit S. [email protected]
wrote:

or try similar thing themselves. I am really stuck on this.
Maybe try:

match 'draw/load' => 'draw#load'

instead?

On 20 May 2013 20:44, Hassan S. [email protected]
wrote:

On Mon, May 20, 2013 at 12:20 PM, Rochit S. [email protected] wrote:

So in this case i would need to do
addition in
Routes.rb for each controller/action.? Is there no rule that can be set
In routes.rb?

Recommended reading: Rails Routing from the Outside In — Ruby on Rails Guides

And all the other guides in fact, there are a number of changes since
Rails 2. It might be worth skimming through the tutorial at
railstutorial.org (which is free to use online) to see how much has
changed.

Colin

On Tuesday, May 21, 2013 1:35:37 AM UTC-4, tamouse wrote:

case,
I looked at the guide and also entered:
get ‘draw#load’
This is still not working. Can someone please send me a working example
or try similar thing themselves. I am really stuck on this.

Maybe try:

match 'draw/load' => 'draw#load'

instead?

sorry, I missed something. no rhtml files. View files end in html.erb
(for embedded ruby/html) or haml. the above match statement should
work.

On Tuesday, May 21, 2013 1:35:37 AM UTC-4, tamouse wrote:

case,
I looked at the guide and also entered:
get ‘draw#load’
This is still not working. Can someone please send me a working example
or try similar thing themselves. I am really stuck on this.

Maybe try:

match 'draw/load' => 'draw#load'

instead?

I missed something in your original post. The above match statement
should
work with 3.2 for routing, but your view file needs to end in html.erb
for
embedded ruby, or haml. rhtml isn’t recognized. I also echo Colin’s
post,
there’s a lot that has changed with Rails and spending some time with a
decent tutorial and/or the edge guides would ease the transition
considerably.

mike wrote in post #1109705:

On Tuesday, May 21, 2013 1:35:37 AM UTC-4, tamouse wrote:

case,
I looked at the guide and also entered:
get ‘draw#load’
This is still not working. Can someone please send me a working example
or try similar thing themselves. I am really stuck on this.

Maybe try:

match 'draw/load' => 'draw#load'

instead?

I missed something in your original post. The above match statement
should
work with 3.2 for routing, but your view file needs to end in html.erb
for
embedded ruby, or haml. rhtml isn’t recognized. I also echo Colin’s
post,
there’s a lot that has changed with Rails and spending some time with a
decent tutorial and/or the edge guides would ease the transition
considerably.

Hi Mike,
Yes the issue was that i was using a .rhtml file. I created .erb and it
worked :slight_smile:
Thanks a lot all for helping out.