少於 1 分鐘閱讀

Route

# [path] config/routes.rb 
root 'topics#index' #root page , go to  controllor"topic" and method"welcome"
get 'welcome', to: 'topics#welcome'  # /welcome page, go to  controllor"topic" and method"welcome"
redirect_to: XXX_path #like php header('[URL]')

Assets

//= require_tree . 

is the last thing to be required. The reason is, //= require_tree . compiles each of the other Javascript files in the javascripts directory and any subdirectories.

keywords

belongs_to :group, counter_cache: :posts_count

build a count cache .. and need to change <%= group.posts.count %> to <%= group.posts.size %>

留言