For you Ruby on Rails fans, this might be a very simple question. I have been handed control of a RR site (none on our team handle RR), which is in the middle of being completely rebuilt with PHP. In the mean time, the client has requested that the existing site display only an image, nothing more.
What is the easiest way to do this? What would the code look like and where do I put that code?
I have attempted to change the routing code, but that has had no effect. I didn't even break the website.
I would appreciate any RR help!
In your app/views/layouts/application.html.haml do this:
!!!
%html
%head
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag 'application', 'data-turbolinks-track' => true
= csrf_meta_tags
%body
= yield
Then in your terminal type rails g controller Pages index
Then go to app/views/pages/index.html.haml and put this
= image_tag "/images/image.jpg", class: '', alt: ''
You can remove width, class and alt if you don't need it. And you need to put your image inside app/images/
Now go to your routes.rb and put this:
Rails.application.routes.draw do
root 'pages#index'
end
您应该能够简单地在public
目录中创建具有所需内容的index.html
文件。
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.