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

273 views
Skip to first unread message

Rochit Sen

unread,
May 20, 2013, 1:26:20 PM5/20/13
to rubyonra...@googlegroups.com
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.

--
Posted via http://www.ruby-forum.com/.

mike

unread,
May 20, 2013, 3:15:22 PM5/20/13
to rubyonra...@googlegroups.com
You need to configure the route in the config/routes.db file.  In this case, 

 get 'draw#load'


Rochit Sen

unread,
May 20, 2013, 3:20:56 PM5/20/13
to rubyonra...@googlegroups.com
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?

Hassan Schroeder

unread,
May 20, 2013, 3:44:31 PM5/20/13
to rubyonra...@googlegroups.com
On Mon, May 20, 2013 at 12:20 PM, Rochit Sen <li...@ruby-forum.com> 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: http://guides.rubyonrails.org/routing.html

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

Colin Law

unread,
May 20, 2013, 4:09:39 PM5/20/13
to rubyonra...@googlegroups.com
On 20 May 2013 20:44, Hassan Schroeder <hassan.s...@gmail.com> wrote:
> On Mon, May 20, 2013 at 12:20 PM, Rochit Sen <li...@ruby-forum.com> 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: http://guides.rubyonrails.org/routing.html

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

Rochit Sen

unread,
May 21, 2013, 1:01:33 AM5/21/13
to rubyonra...@googlegroups.com
Rochit Sen wrote in post #1109638:
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

tamouse mailing lists

unread,
May 21, 2013, 1:35:37 AM5/21/13
to rubyonra...@googlegroups.com
Maybe try:

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

instead?
Message has been deleted

mike

unread,
May 21, 2013, 9:13:51 AM5/21/13
to rubyonra...@googlegroups.com
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.

Rochit Sen

unread,
May 21, 2013, 12:07:14 PM5/21/13
to rubyonra...@googlegroups.com
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 :)
Thanks a lot all for helping out.
Reply all
Reply to author
Forward
0 new messages