Skip to content

Instantly share code, notes, and snippets.

source 'https://rails-assets.org'
gem 'rails-assets-jquery-mobile-bower'
gem 'rails-assets-iscroll', '5.1.2'
class Photo < ActiveRecord::Base
belongs_to :post, :class_name => "Forem::Post"
has_attached_file :attachment,
path: ":rails_root/public/system/attachments/:id/:style/:filename",
url: "/system/attachments/:id/:style/:filename",
styles: {
display: "450x450>",
thumbnail: "70x70#"
},
alias x=my_alias
def my_alias
command 1
command 2
command 3
end
def forem_emojify(content)
h(content).to_str
# Convert regular emoticons
.gsub(' :)', ' :smile:')
.gsub(' ;)', ' :wink:')
.gsub(' :D', ' :laughing:')
.gsub(' :P', ' :stuck_out_tongue:')
.gsub(' :p', ' :stuck_out_tongue:')

How does one run a function from application.js inside a .js.erb file?

I'd rather not have to duplicate said function.

DOESN'T WORK

app/assets/javascripts/application.js

$(document).on('pagecontainershow', function() {
  function someOtherFunction() {
 console.log('Hello world')