2016-04-18 9 views
5

का उपयोग कर विभिन्न पृष्ठों में बदलती है मैं संपत्ति स्टाइलशीट का उपयोग करके एक सीएसएस लोड करता हूं। हालांकि यह केवल सूचकांक में लोड होता है। जब मैंने f12 का उपयोग किया तो कंसोल इंडेक्स के अलावा अन्य पृष्ठों के लिए यूआरएल दिखाता है। कहते हैं/कपड़ा डिफ़ॉल्ट लेआउट जो application.html.erb है का उपयोग कर iamमेरी सीएसएस संपत्ति यूआरएल अचानक रेल पेज

route.rb

Rails.application.routes.draw do 
    resources :categories 
    resources :cloths 
end 

cloths_controller.rb

class ClothsController < ApplicationController 
    before_action :set_cloth, only: [:show, :edit, :update, :destroy] 


    # GET /cloths 
    # GET /cloths.json 
    def index 
    @cloths = Cloth.all 
    @categories = Category.all 
    end 

    # GET /cloths/1 
    # GET /cloths/1.json 
    def show 
    @cloths = Cloth.all 
    @comments = Comment.where("cloth_id = ?", @cloth.id) 
    @comments = Comment.paginate(:page => params[:page], :per_page => 3) 
    end 

    # GET /cloths/new 
    def new 
    @cloth = Cloth.new 
    @categories = Category.all 
    respond_to do|format| 
     format.html #new.html.erb 
     format.xml{render :xml=>@recipe} 
     end 
    end 

    # GET /cloths/1/edit 
    def edit 
    end 

    # POST /cloths 
    # POST /cloths.json 
    def create 
    @cloth = Cloth.new(cloth_params) 

    respond_to do |format| 
     if @cloth.save 
     format.html { redirect_to @cloth, notice: 'Cloth was successfully created.' } 
     format.json { render :show, status: :created, location: @cloth } 
     else 
     format.html { render :new } 
     format.json { render json: @cloth.errors, status: :unprocessable_entity } 
     end 
    end 
    end 

    # PATCH/PUT /cloths/1 
    # PATCH/PUT /cloths/1.json 
    def update 
    respond_to do |format| 
     if @cloth.update(cloth_params) 
     format.html { redirect_to @cloth, notice: 'Cloth was successfully updated.' } 
     format.json { render :show, status: :ok, location: @cloth } 
     else 
     format.html { render :edit } 
     format.json { render json: @cloth.errors, status: :unprocessable_entity } 
     end 
    end 
    end 

    # DELETE /cloths/1 
    # DELETE /cloths/1.json 
    def destroy 
    @cloth.destroy 
    respond_to do |format| 
     format.html { redirect_to cloths_url, notice: 'Cloth was successfully destroyed.' } 
     format.json { head :no_content } 
    end 
    end 

    def men 
    end 


#PRIVATE 
    private 
    # Use callbacks to share common setup or constraints between actions. 
    def set_cloth 
     @cloth = Cloth.find(params[:id]) 
    end 
    def cloth_params 
     params.require(:cloth).permit(:title, :category_id, :description) 
    end 

end 

application.html.erb

<!DOCTYPE HTML> 
<html> 
<head> 
<title>Batik</title> 
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

<link href="assets/bootstrap.css" rel='stylesheet' type='text/css' /> 
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
<script src="assets/simpleCart.min.js"> </script> 
<script src="assets/jquery.min.js"></script> 
<!-- Custom Theme files --> 
<link href="assets/style.css" rel='stylesheet' type='text/css' /> 
<!-- Custom Theme files --> 
<!--webfont--> 
<link href='http://fonts.googleapis.com/css?family=Raleway:100,200,300,400,500,600,700,800,900' rel='stylesheet' type='text/css'> 
<link href='http://fonts.googleapis.com/css?family=Audiowide' rel='stylesheet' type='text/css'> 
<script src="assets/jquery.easydropdown.js"></script> 
<!-- Add fancyBox main JS and CSS files --> 
<script src="assets/jquery.magnific-popup.js" type="text/javascript"></script> 
<link href="assets/magnific-popup.css" rel="stylesheet" type="text/css"> 
    <script> 
     $(document).ready(function() { 
     $('.popup-with-zoom-anim').magnificPopup({ 
      type: 'inline', 
      fixedContentPos: false, 
      fixedBgPos: true, 
      overflowY: 'auto', 
      closeBtnInside: true, 
      preloader: false, 
      midClick: true, 
      removalDelay: 300, 
      mainClass: 'my-mfp-zoom-in' 
     }); 
    }); 
    </script> 
</head> 
<body> 



    <%#=debug(session)%> 
    <%= yield %> 
<!--Footer--> 
<div class="container"> 
     <div class="brands"> 
     <ul class="brand_icons"> 
     <li><img src='assets/icon1.jpg' class="img-responsive" alt=""/></li> 
     <li><img src='assets/icon2.jpg' class="img-responsive" alt=""/></li> 
     <li><img src='assets/icon3.jpg' class="img-responsive" alt=""/></li> 
     <li><img src='assets/icon4.jpg' class="img-responsive" alt=""/></li> 
     <li><img src='assets/icon5.jpg' class="img-responsive" alt=""/></li> 
     <li><img src='assets/icon6.jpg' class="img-responsive" alt=""/></li> 
     <li class="last"><img src='assets/icon7.jpg' class="img-responsive" alt=""/></li> 
     </ul> 
     </div> 
     </div> 
     <div class="container"> 
     <div class="instagram_top"> 
      <div class="instagram text-center"> 
     <h3><i class="insta_icon"> </i> Instagram feed:&nbsp;<span class="small">#Surfhouse</span></h3> 
     </div> 
      <ul class="instagram_grid"> 
     <li><a class="popup-with-zoom-anim" href="#small-dialog1"><img src="assets/i1.jpg" class="img-responsive"alt=""/></a></li> 
     <li><a class="popup-with-zoom-anim" href="#small-dialog1"><img src="assets/i2.jpg" class="img-responsive" alt=""/></a></li> 
     <li><a class="popup-with-zoom-anim" href="#small-dialog1"><img src="assets/i3.jpg" class="img-responsive" alt=""/></a></li> 
     <li><a class="popup-with-zoom-anim" href="#small-dialog1"><img src="assets/i4.jpg" class="img-responsive" alt=""/></a></li> 
     <li><a class="popup-with-zoom-anim" href="#small-dialog1"><img src="assets/i5.jpg" class="img-responsive" alt=""/></a></li> 
     <li class="last_instagram"><a class="popup-with-zoom-anim" href="#small-dialog1"><img src="assets/i6.jpg" class="img-responsive" alt=""/></a></li> 
     <div class="clearfix"></div> 
     <div id="small-dialog1" class="mfp-hide"> 
     <div class="pop_up"> 
      <h4>A Sample Photo Stream</h4> 
      <img src="assets/i_zoom.jpg" class="img-responsive" alt=""/> 
     </div> 
     </div> 
     </ul> 
     </div> 
     <ul class="footer_social"> 
     <li><a href="#"> <i class="fb"> </i> </a></li> 
     <li><a href="#"><i class="tw"> </i> </a></li> 
     <li><a href="#"><i class="pin"> </i> </a></li> 
     <div class="clearfix"></div> 
     </ul> 
     </div> 
    </div> 

</body> 
</html> 

सब कुछ index.html पर ठीक काम करता है लेकिन शो में, सभी संपत्ति यूआरएल संपादित और संपादित करते हैं। इस

GET http://localhost:3000/cloths/assets/bootstrap.css (404 could not found) 

क्यों यूआरएल अचानक "/ कपड़ा/संपत्ति" के बजाय सिर्फ "/ संपत्ति"

उत्तर

3

आप अपने config/application.rb को config.assets.paths << Rails.root.join('app', 'assets', 'cloths') जोड़ने के लिए कपड़ा/आस्तियों/संपत्ति से सुलभ बनाने के लिए जरूरत के लिए बदल जाती है जैसे आपके applicaion

+1

हाँ यह काम किया! हालांकि मुझे अपनी संपत्ति के सामने "/" जोड़कर पता चला था एक बेहतर समाधान thx btw था। –

संबंधित मुद्दे