2011-12-09 11 views
0

私はいくつかのCSSとJSコードと共に作成したhtmlホームページを持っています。私はこれを私のRubyアプリケーションにホームページとして取り込みたいと思っています。私のconfig/routes.rbを、私はこれがあります。ruby​​ホームページをhtmlファイルに変更する

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

を、私のfirst_controllerに私はこれがあります。

class FirstControllerController < ApplicationController 

    def index 
     @users = User.all 
    end 

end 

は、私は私のhtmlファイルにリダイレクトdef homeメソッドを作成できますか?

@users = User.allは本の読書のコードで、ルビーのアプリを作る方法を教えてくれて、自分のニーズに合わせて修正しています。 THX

答えて

0

あなたはそれが単純なHTMLであることから、あなたはレールがそれをキャッシュさせることができ、また

class FirstControllerController < ApplicationController 

    def index 
    @users = User.all 
    end 

    def home 
    render :template => "relative/path/from/views", :layout => false 
    end 

end 

を行うことができます。あなたのコントローラにcaches_page :homeを追加してください。

編集:フォーマット

関連する問題