2013-09-27 2 views
0

도와주세요. 제가 레일 프로젝트 작업 중이며 확장자가 .html.haml 인보기 파일을 만들었지 만 지금 보려고 할 때 그 파일의 출력은 오류를 일으킨다. 거기에 다른 확장자의 파일을 볼 수있는 방법이 있습니까, 나는 exyension .html.erb로 내 파일을 보는 데 사용하는 방법을 사용하고 있습니다. 컨트롤러 nd에서 routes.rb의 경로와 일치하는 작업을 만들었습니다. 제발 도와주세요, 미리 감사드립니다.
내 routes.rb 파일확장명이 .html.haml 인 파일의 출력을 보는 방법

PretAChef::Application.routes.draw do 

    # mount FeatherCms::Engine => "/feathers" 

    # get 'pages/:name' => 'feather_cms/pages#published', :as => 'feather_published_page' 
    resources :messages, only: [:destroy, :show] do 
    member do 
     post :reply 
     get :mark_read 
    end 
    end 

    resources :bookings, only: [] do 
    resources :messages, only: [:new, :create] 
    end 


    resources :chefs, :only => [:index, :show] do 
     member do 
     get :feedbacks 
    end 
    end 
    resources :customers, :only => [] do 
    member do 
     get :feedbacks 
    end 
    end 

    resources :ingredients, only: [:index] 

    resources :cuisines, only: [:index] 

    resources :home do 
    collection do 
     post :contact 
    end 
    end 
    root :to => 'home#index' 
    match 'contact_us' => 'home#contact_us', :as => :contact_us 
    match 'mypop' => 'chefs#mypop', :as => :mypop 

    devise_for :users, :controllers => {:registrations => "users/registrations", :sessions => "users/sessions", :passwords => "users/passwords", :confirmations => "users/confirmations", :omniauth_callbacks => "users/omniauth_callbacks" } 

    devise_scope :user do 
    match "/chef/sign_up" => "users/registrations#new_chef", as: :chef_sign_up 
    match "/chef/sign_in" => "users/sessions#new_chef", as: :chef_sign_in 
    match "https://stackoverflow.com/users/sign_out" => "users/sessions#destroy", as: :sign_out 
    end 

    resource :profiles, :only => [:edit, :update] do 
    end 

    namespace :customer do 
    resource :dashboards, only: [:show] 
    resources :bookings, :only => [:create, :update, :edit, :destroy] do 
     collection do 
     get :booking_confirmation 
     get :book_chef 
     end 
     member do 
     # TODO: WTF: use destroy for cancelation 
     post :rate 
     post :comment 
     get :feedback 
     get :pay 
     get :complete 
     get :confirm 
     end 
    end 
    end 

    namespace :admin do 
    resources :messages, only: [:index, :show] do 
     collection do 
     get :contact_us 
     get :messages 
     end 
    end 
    resources :cuisines, except: [:show] 
    resources :bookings, only: [:index, :update, :edit, :destroy] 


    resources :users, only: [:index, :update, :edit] do 
     collection do 
     get :active 
     get :pending 
     end 
     resources :menus, except: [:index] do 
     collection do 
      post :preview 
      get :destory_dish_image 
     end 
     end 
     resources :availabilities, only: [:create, :destroy] 
     resources :chef_messages, only: [:destroy, :show, :index, :new, :create] do 
     member do 
      post :reply 
      get :mark_read 
     end 
     end 

     namespace :chef do 
     resources :bookings, only: [:edit, :update] do 
      member do 
      get :accept 
      post :rate 
      post :comment 
      get :feedback 
      end 
     end 
     end 

    end 

    resources :searches, only: [:index] do 
     collection do 
     get "user" 
     end 
    end 
    end 

    namespace :chef do 
    resources :bookings, only: [:edit, :update] do 
     member do 
     get :accept 
     post :rate 
     post :comment 
     get :feedback 
     end 
    end 
    resource :dashboards, only: [:show] 
    resources :menus, except: [:index] do 
     collection do 
     post :preview 
     get :destory_dish_image 
     end 
    end 
    resources :availabilities, only: [:create, :destroy] 
    end 

    # The priority is based upon order of creation: 
    # first created -> highest priority. 

    # Sample of regular route: 
    # match 'products/:id' => 'catalog#view' 
    # Keep in mind you can assign values other than :controller and :action 

    # Sample of named route: 
    # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase 
    # This route can be invoked with purchase_url(:id => product.id) 

    # Sample resource route (maps HTTP verbs to controller actions automatically): 
    # resources :products 

    # Sample resource route with options: 
    # resources :products do 
    #  member do 
    #  get 'short' 
    #  post 'toggle' 
    #  end 
    # 
    #  collection do 
    #  get 'sold' 
    #  end 
    # end 

    # Sample resource route with sub-resources: 
    # resources :products do 
    #  resources :comments, :sales 
    #  resource :seller 
    # end 

    # Sample resource route with more complex sub-resources 
    # resources :products do 
    #  resources :comments 
    #  resources :sales do 
    #  get 'recent', :on => :collection 
    #  end 
    # end 

    # Sample resource route within a namespace: 
    # namespace :admin do 
    #  # Directs /admin/products/* to Admin::ProductsController 
    #  # (app/controllers/admin/products_controller.rb) 
    #  resources :products 
    # end 

    # You can have the root of your site routed with "root" 
    # just remember to delete public/index.html. 
    # root :to => 'welcome#index' 

    # See how all your routes lay out with "rake routes" 

    # This is a legacy wild controller route that's not recommended for RESTful applications. 
    # Note: This route will make all actions in every controller accessible via GET requests. 
    # match ':controller(/:action(/:id))(.:format)' 
end 

이며, 내보기 파일

!!! 
%html 
    %head 
    :css 
     /* popup_box DIV-Styles*/ 
     #popup_box { 
      display:none; /* Hide the DIV */ 
      position:fixed; 
      _position:absolute; /* hack for internet explorer 6 */ 
      height:300px; 
      width:600px; 
      background:#FFFFFF; 
      left: 300px; 
      top: 150px; 
      z-index:100; /* Layering (on-top of others), if you have lots of layers: I just maximized, you can change it yourself */ 
      margin-left: 15px; 

      /* additional features, can be omitted */ 
      border:2px solid #ff0000;  
      padding:15px; 
      font-size:15px; 
      -moz-box-shadow: 0 0 5px #ff0000; 
      -webkit-box-shadow: 0 0 5px #ff0000; 
      box-shadow: 0 0 5px #ff0000; 

     } 

     #container { 
      background: #d2d2d2; /*Sample*/ 
      width:100%; 
      height:100%; 
     } 

     a{ 
     cursor: pointer; 
     text-decoration:none; 
     } 

     /* This is for the positioning of the Close Link */ 
     #popupBoxClose { 
      font-size:20px; 
      line-height:15px; 
      right:5px; 
      top:5px; 
      position:absolute; 
      color:#6fa5e2; 
      font-weight:500;  
     } 
    %title Popup Box DIV 
    %script{src: "http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js", type: "text/javascript"} 
    :javascript 
     $(document).ready(function() { 

      // When site loaded, load the Popupbox First 
      loadPopupBox(); 

      $('#popupBoxClose').click(function() {    
       unloadPopupBox(); 
      }); 

      $('#container').click(function() { 
       unloadPopupBox(); 
      }); 

      function unloadPopupBox() { // TO Unload the Popupbox 
       $('#popup_box').fadeOut("slow"); 
       $("#container").css({ // this is just for style   
        "opacity": "1" 
       }); 
      }  

      function loadPopupBox() { // To Load the Popupbox 
       $('#popup_box').fadeIn("slow"); 
       $("#container").css({ // this is just for style 
        "opacity": "0.3" 
       });   
      }   
     }); 
    %body 
    #popup_box 
    /OUR PopupBox DIV 
     %h1 This IS A Cool PopUp 
     %a#popupBoxClose Close 
    #container 
    /Main Page 
     %h1 sample 

이고 내 행동이 요리사 컨트롤러에 mypop입니다.

+0

무엇이 오류입니까? –

+0

@RajeshKolappakam 문제는 내가 그 haml 파일 bt를 보여주기 위해 정의한 행동에 그것을 보내려고한다는 것입니다. 대신 그 메소드에 가서 그 컨트롤러의 다른 메소드로 가서 에러를 보여 주려고합니다. 어떻게해야할지 말해줘. –

+0

'routes.rb' 파일을 게시 할 수 있습니까 –

답변

0

보석을 설치하지 않은 것 같습니다. gemfile에 gem "haml"을 추가하기 만하면됩니다. 번들 설치 실행

이제 끝났습니다.

+0

나는 실제로 프로젝트가 다른 누군가에 의해 수행 된 보석을 설치했다. 그리고 지금 그것은 약간의 수정을 위해 나에게왔다. 그리고 나의 측에서 그것의 view 폴더에 새로운 파일을 추가했다. 다른 파일들도 같은 확장자를 가진다. 실행 중입니다. –

+0

나는 항상 .haml 확장자를 가진 사용자 파일을 가지고 있지 않다. 레일즈에 익숙하지 않다. 항상 .html.erb 확장자를 가진 파일을 사용했다. –

0

먼저 모든 CSS와 스크립트를 템플릿 자체가 아닌 자산에 배치해야하며 두 번째로 문제를 조금 설명 할 수 있어야합니다. 나는 어떤 행동을하고 있는지, 파일을 어떻게 렌더링하고 어떤 행동을 취하는지를 뜻합니다.

+0

괜찮아요 내 자산에 모든 내 CSS를 넣을거야 둘째 문제는 내가 그 mypop.html.haml 파일의 출력을 보려고하고 그게 내가 요리사 컨트롤러에서 작업을 생성하고 그 경로가 내 routes.rb 파일을 볼 수 있습니다. routes.rb 파일에서 오류를 표시하고 o/p를 표시하지 않습니다. –

+0

@IshanSharma 어떤 오류가 표시됩니까? – Mandeep

+0

문제는 내가 그 haml 파일 bt를 보여주는 대신에 그 컨트롤러의 다른 메소드로 가서 그 안에 에러를 보여주는 대신에 그 메소드로가는 것을 보여주기 위해 정의한 액션으로 보내려고한다는 것이다. 어떻게해야할지 말해줘. –

관련 문제