Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • T torque-postgresql
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 6
    • Issues 6
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Carlos
  • torque-postgresql
  • Wiki
  • Dynamic Attributes

Dynamic Attributes · Changes

Page history
Updated Dynamic Attributes (markdown) authored Aug 18, 2018 by Carlos's avatar Carlos
Hide whitespace changes
Inline Side-by-side
Dynamic-Attributes.md
View page @ 20712242
...@@ -7,8 +7,11 @@ This method allows defining a conditional value that, if present in the result s ...@@ -7,8 +7,11 @@ This method allows defining a conditional value that, if present in the result s
In any model, you just need to call `dynamic_attribute` method, passing an name for it and the block that will be called in case the attribute is not present. In any model, you just need to call `dynamic_attribute` method, passing an name for it and the block that will be called in case the attribute is not present.
```ruby ```ruby
dynamic_attribute(:last_comment) do # models/user.rb
comments.order(id: :desc).first.content class User < ActiveRecord::Base
dynamic_attribute(:last_comment) do
comments.order(id: :desc).first.content
end
end end
``` ```
......
Clone repository
  • Wiki
  • Configuring

Data types

  • Enum
  • Interval

Querying

  • Dynamic Attributes
  • Distinct On
  • Auxiliary Statements