简体   繁体   中英

Error when creating static pages

I'm trying to create two static pages and I have the following error:

Missing template static_pages/index with {:formats=>[:html], :locale=>[:en, :en], :handlers=>[:rhtml, :rxml, :builder, :erb, :rjs]} in view paths "F:/assignment/app/views"

I am new to rails and web development in general, so it's probably something simple.

I have followed this link to get to the stage I am now at: Static pages in Ruby on Rails

I am trying to create two static pages, one called About and one called Help in a basic blog application. When I have created the controller I have called it 'static_pages' as I already have a pages controller.

Can anybody offer any advice on where I'm going wrong?

I hope I understand you correctly if I say you want a path like localhost:3000/About

In that case, you want to create a method with the same name as the view (About.html) in your static_pages controller.

def About
end

( Notice case sensitivity )

The About.html file should be placed within the /static_pages directory. And in the routes.rb file, you should have:

match '/About' => 'static_pages#About'

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM