Layouts_path

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.

What is the output of “rake routes” when you run it from a command line?
Have you actually defined a layouts path?

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.

I have the book and here’s the link:

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

Thanks

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.

On 19 October 2012 19:02, Drew D. [email protected] 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

Colin L. wrote in post #1080478:

On 19 October 2012 19:02, Drew D. [email protected] 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.

Thanks - Drew

On 22 October 2012 14:12, Drew D. [email protected] 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

Colin L. wrote in post #1080669:

On 22 October 2012 14:12, Drew D. [email protected] 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. 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

On 22 October 2012 15:56, Drew D. [email protected] wrote:

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.

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs