Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

common functions in rails

# lib/my_utilities.rb

module MyUtilities
  def trim_string(string)
    do_something
  end    
end

#Then in controller or model where you want this:
# models/foo.rb

require 'my_utilities'

class Foo < ActiveRecord::Base
  include MyUtilities

  def foo(a_string)
    trim_string(a_string)
    do_more_stuff
  end
end
Comment

PREVIOUS NEXT
Code Example
Ruby :: ruby URI.open with proxy 
Ruby :: self join relationship rails 
Ruby :: refactor duplicate tests rspec 
Ruby :: reduce ruby baud rate 
Ruby :: Or even multiple scope parameters. For example, making sure that a teacher can only be on the schedule once per semester for a particular class. 
Ruby :: how to group array in ruby 
Ruby :: rails update column without callbacks 
Ruby :: find records using the IN expression in Rails 
Ruby :: ruby String split second parameter 
Ruby :: add extension in ruby tempfile object 
Ruby :: simpleCov formatter set two formats 
Ruby :: how to make rails 
R :: r list files in directory 
R :: r remove leading and trailing whitespace 
R :: r import table with readr 
R :: r column to rownames 
R :: r heatmap 
R :: Write data from R to clipboard 
R :: how to substring in R from position 
R :: how to read multiple csv files from a directory in r 
R :: convert string to lowercase R 
R :: r function syntax 
R :: knn in r 
R :: read.table 
R :: two string in one string r 
R :: barplot_spacewidth 
R :: select last child with class in r 
R :: extract first element before a character stringr 
R :: Print the names of all worksheets in r 
Rust :: rust get current directory 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =