简体   繁体   English

Ruby on Rails新手,如何将站点重定向到图像?

[英]Ruby on Rails novice, how to redirect site to image?

For you Ruby on Rails fans, this might be a very simple question. 对于您的Ruby on Rails粉丝来说,这可能是一个非常简单的问题。 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. 我已经获得了一个RR站点的控制权(在我们的团队中没有人处理RR),而该站点正被PHP完全重建。 In the mean time, the client has requested that the existing site display only an image, nothing more. 同时,客户要求现有站点仅显示图像,仅此而已。

  • The image would be hosted within the "public" folder within the RR framework. 该图像将托管在RR框架内的“ public”文件夹中。
  • They want the entire site to become an un-clickable image. 他们希望整个站点成为不可点击的图像。

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! 我会感谢任何RR帮助!

In your app/views/layouts/application.html.haml do this: 在您的app / views / layouts / application.html.haml中执行以下操作:

!!!
%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 然后在终端中输入rails g controller Pages index

Then go to app/views/pages/index.html.haml and put this 然后转到app / views / pages / index.html.haml并将其放入

   = image_tag "/images/image.jpg", class: '', alt: ''

You can remove width, class and alt if you don't need it. 如果不需要,可以删除width,class和alt。 And you need to put your image inside app/images/ 而且您需要将图片放入app / images /

Now go to your routes.rb and put this: 现在转到您的routes.rb并输入以下内容:

Rails.application.routes.draw do
  root 'pages#index'
end

您应该能够简单地在public目录中创建具有所需内容的index.html文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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