Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

ruby on rails project

class Article < ApplicationRecord
  belongs_to :author, default: -> { Current.user }
  has_many   :comments

  has_one_attached :avatar
  has_rich_text :content, encrypted: true
  enum status: [ :drafted, :published ]

  scope :recent, -> { order(created_at: :desc).limit(25) }

  after_save_commit :deliver_later, if: :published?

  def byline
    "Written by #{author.name} on #{created_at.to_s(:short)}"
  end

  def deliver_later
    Article::DeliveryJob.perform_later self
  end
end
Comment

PREVIOUS NEXT
Code Example
Ruby :: get directory of current file ruby 
Ruby :: time_ago_in_words for created_at model in rails 
Ruby :: api blueprint minitest rails 
R :: r define nested empty list 
R :: how to count the number of NA in r 
R :: Drop rows with missing values in R 
R :: remove elements from character vector in r 
R :: r extract everything before character 
R :: reverse row order dataframe R 
R :: r split string column by delimiter 
R :: merge several data frames in r 
R :: how to group by 2 variables in r 
R :: rename column in r 
R :: custom function in r 
R :: how to extract p value from lm in r 
R :: write text r 
R :: r ggplot stacked bar labels 
R :: r matrix 
R :: how to create for loop through columns and count non na cells by group in r 
R :: how to tell if a variable is discrete or continuous in r 
R :: how to bootstrap in r 
R :: read delim in r with lapply read.delim sep 
R :: how to bootstrap in r with resampling 
R :: select last child with class in r 
R :: pairing in r 
R :: how to rename variables in r 
R :: conditional mean statement r 
Rust :: how to read from stdin rust 
Rust :: 2d vector rust 
Rust :: rust vec to array 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =