Take existing project and move it into a Ruby on Rails environment -
i have front end of website built. made number of html, javascript, , jquery files. there way take files , move them ruby on rails environment don't need remake everything?
sure. create new rails app (rails new app-name
). copy existing javascript files rails project @ public/javascripts/
. views/html bit more dependent on how want grow.
one option create single pagescontroller
, not bother resources/models/etc, , put of "views" /app/views/pages/
. don't have rename them .html.erb
conventionally see — you can leave them plain html. routes.rb file this:
get '/:action', :controller => 'pages', :as => 'page'
which afford routes "example.com/hello_world" route pagescontroller#hello_world, rendering "app/views/pages/hello_world.html". if want use erb, can add ".erb" suffix view file , can use page_path
helper assemble links:
<%= link_to 'hello world demo', page_path('hello_world') %>
you still want extract common elements layout @ app/views/layouts/application.html.erb
(again, erb being optional).
another route separate application resources. if have page lists books, example, create bookscontroller , put relevant view under app/views/books/index.html
. doesn't make sense if you're not going provide additional functionality in future, though.
Comments
Post a Comment