This commit is contained in:
parent
443db292e9
commit
d13bd95045
|
@ -11,3 +11,51 @@ in config/environments/development.rb:
|
||||||
|
|
||||||
# Don't break apart
|
# Don't break apart
|
||||||
config.assets.debug = false
|
config.assets.debug = false
|
||||||
|
|
||||||
|
Partial locals
|
||||||
|
|
||||||
|
<%= render 'article', full: true %>
|
||||||
|
<%= render 'article' %>
|
||||||
|
|
||||||
|
<% if local_assigns[:full] %>
|
||||||
|
...
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
HTML in i18n
|
||||||
|
|
||||||
|
en:
|
||||||
|
read_more_html: "read <b>more</b>..."
|
||||||
|
|
||||||
|
Exception handling:
|
||||||
|
|
||||||
|
# config/application.rb
|
||||||
|
config.exceptions_app = self.routes
|
||||||
|
|
||||||
|
get '/404', to: 'errors#not_found'
|
||||||
|
get '/500', to: 'errors#server_error'
|
||||||
|
|
||||||
|
class ErrorsController
|
||||||
|
def not_found
|
||||||
|
render status: :not_found
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Rails updating:
|
||||||
|
|
||||||
|
rake rails:update
|
||||||
|
|
||||||
|
Distinct pluck:
|
||||||
|
|
||||||
|
Article.distinct.pluck('author')
|
||||||
|
|
||||||
|
Relation#merge
|
||||||
|
|
||||||
|
scope :with_drafts, -> {
|
||||||
|
uniq.joins(:articles).merge(Article.draft)
|
||||||
|
}
|
||||||
|
|
||||||
|
Order
|
||||||
|
|
||||||
|
scope :recent, -> { order created_at: :desc }
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue