locomotiveCMS使用心得和疑问
疑问:
它是如何实现当进行 rails generate scaffold Dish ...的时候不产生db/migrate文件,使得rake db:migrate失效的?而且自动生成的controller中没有内容。
使用心得:
view/admin/pages/index.html.haml中
- content_for :buttons do
??= admin_button_tag :new, new_admin_page_url, :class => 'new'
base_helper.rb
?
def admin_button_tag(text, url, options = {})
?? ?text = text.is_a?(Symbol) ? t(".#{text}") : text
?? ?link_to(url, options) do
?? ? ?content_tag(:em, escape_once(' ')) + text
?? ?end
??end
is_a是我理解为测试它是否为Symbol的一个实例,这里的:new我估计是根据new_admin_page_url来推出的locale中的值,即admin.pages.new,但为什么是这么智能,我还没能理解。