layouts_path

10 views
Skip to first unread message

Drew Drew

unread,
Oct 19, 2012, 1:25:00 PM10/19/12
to rubyonra...@googlegroups.com
I'm very new to RoR and am receiving the following error on rspec spec/

1) Layouts GET /layouts works! (now write some real specs)
Failure/Error: get layouts_path
NameError:
undefined local variable or method `layouts_path' for
#<RSpec::Core::ExampleGroup::Nested_5::Nested_1:0x007f8adc382020>
# ./spec/requests/layouts_spec.rb:7:in `block (3 levels) in <top
(required)>'

My layouts_spec.rb looks like the following:

require 'spec_helper'

describe "Layouts" do
describe "GET /layouts" do
it "works! (now write some real specs)" do
# Run the generator again with the --webrat flag if you want to
use webrat methods/matchers
get layouts_path
response.status.should be(200)
end
end
end


Does anyone have an idea of the problem? Thanks in advance for any
replies. Cheers.

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

Timster

unread,
Oct 19, 2012, 1:39:01 PM10/19/12
to rubyonra...@googlegroups.com
What is the output of "rake routes" when you run it from a command line? Have you actually defined a layouts path?

Drew Davis

unread,
Oct 19, 2012, 1:44:10 PM10/19/12
to rubyonra...@googlegroups.com
Thanks!

rake routes output:

users_new GET /users/new(.:format) users#new
signup /signup(.:format) users#new
contact /contact(.:format) pages#contact
about /about(.:format) pages#about
help /help(.:format) pages#help
root / pages#home
pages_home GET /pages/home(.:format) pages#home
pages_about GET /pages/about(.:format) pages#about
pages_contact GET /pages/contact(.:format) pages#contact
pages_help GET /pages/help(.:format) pages#help

I'm running through a tutorial and I'm not sure I have defined the
layouts path yet.

Where should I define the layouts path?

Thanks again.

Timster

unread,
Oct 19, 2012, 1:54:59 PM10/19/12
to rubyonra...@googlegroups.com
You would need to specify this in your routes.rb file. If you post a link to the tutorial you are using, we can help you figure out where in the tutorial it has you defining that path.

Drew Davis

unread,
Oct 19, 2012, 2:02:58 PM10/19/12
to rubyonra...@googlegroups.com
I have the book and here's the link:

http://ruby.railstutorial.org/ruby-on-rails-tutorial-book

Thanks

Colin Law

unread,
Oct 19, 2012, 3:47:36 PM10/19/12
to rubyonra...@googlegroups.com
On 19 October 2012 19:02, Drew Davis <li...@ruby-forum.com> wrote:
> I have the book and here's the link:
>
> http://ruby.railstutorial.org/ruby-on-rails-tutorial-book

To save us searching, which section are you on?

Colin

Drew Davis

unread,
Oct 22, 2012, 9:12:55 AM10/22/12
to rubyonra...@googlegroups.com
Colin Law wrote in post #1080478:
This is actually a slightly different version of the tutorial. I'm on
section 5.3 Layout links and the user sign up page.

Thanks - Drew

Colin Law

unread,
Oct 22, 2012, 9:51:25 AM10/22/12
to rubyonra...@googlegroups.com
On 22 October 2012 14:12, Drew Davis <li...@ruby-forum.com> wrote:
> Colin Law wrote in post #1080478:
>> On 19 October 2012 19:02, Drew Davis <li...@ruby-forum.com> wrote:
>>> I have the book and here's the link:
>>>
>>> http://ruby.railstutorial.org/ruby-on-rails-tutorial-book
>>
>> To save us searching, which section are you on?
>>
>> Colin
>
>
> This is actually a slightly different version of the tutorial. I'm on
> section 5.3 Layout links and the user sign up page.

I can't see any reference to your test layouts_spec.rb in that
section, http://ruby.railstutorial.org/chapters/filling-in-the-layout#sec-layout_links

Colin

Drew Davis

unread,
Oct 22, 2012, 10:56:58 AM10/22/12
to rubyonra...@googlegroups.com
Colin Law wrote in post #1080669:
I'm having a hard time finding the Ruby on Rails 3 Tutorial online. Is
there a different avenue of trouble shooting for this error? The local
variable in layouts_spec.rb is layouts_path and I've looked back through
the book for the layouts_spec.rb file but have found nothing.

Should I just remove this file or move it to a different location?

Is this a necessary file? I removed it and the page still functions and
the tests pass.

I'm just curious where the file came from because I assume it was auto
generated and if removing it will be a problem or cause errors later on
down the line?

Thanks, Drew

Colin Law

unread,
Oct 22, 2012, 11:31:23 AM10/22/12
to rubyonra...@googlegroups.com
On 22 October 2012 15:56, Drew Davis <li...@ruby-forum.com> wrote:
> Colin Law wrote in post #1080669:
>> On 22 October 2012 14:12, Drew Davis <li...@ruby-forum.com> wrote:
>>>
>>> This is actually a slightly different version of the tutorial. I'm on
>>> section 5.3 Layout links and the user sign up page.
>>
>> I can't see any reference to your test layouts_spec.rb in that
>> section,
>> http://ruby.railstutorial.org/chapters/filling-in-the-layout#sec-layout_links
>>
>> Colin
>
> I'm having a hard time finding the Ruby on Rails 3 Tutorial online.

I believe the link I provided is to that tutorial.

> Is
> there a different avenue of trouble shooting for this error? The local
> variable in layouts_spec.rb is layouts_path and I've looked back through
> the book for the layouts_spec.rb file but have found nothing.
>
> Should I just remove this file or move it to a different location?
>
> Is this a necessary file? I removed it and the page still functions and
> the tests pass.
>
> I'm just curious where the file came from because I assume it was auto
> generated and if removing it will be a problem or cause errors later on
> down the line?

Well I certainly have not idea where it came from. Are you using git
(or similar) for version control of your code? If not then you should
be. Then you would know when it was created. The file certainly
looks like something you do not want since you have no model called
Layout, and I suspect it would be a bad idea to have one. Just delete
it and carry on.

Colin
Reply all
Reply to author
Forward
0 new messages