intro_rails

和前端工程师协作

routes.rb

get '/ui(/:action)', controller: 'ui'

ui_controller.rb

class UiController < ApplicationController
  before_action do
    redirect_to :root if Rails.env.production?
  end

  def index
  end
end

app/views/ui/index.html.erb

<ul>
  <% Dir.glob("app/views/ui/*.html.erb").sort.each do |file| %>
  <% wireframe = File.basename(file,'.html.erb') %>
  <% unless wireframe == "index" || wireframe.match(/^_/) %>
    <li><%= link_to wireframe.titleize, action: wireframe %></li>
  <% end %>
 <% end %>
</ul>

把所有的前端页面放到 Ui 目录下。

参考文献:

http://hashrocket.com/blog/posts/managing-design-handoffs-with-the-ui-controller