This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If($is_front){ | |
// do something; | |
} else { | |
// do something; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print_r($node); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Majority of this solution was written and posted here: | |
# http://matharvard.ca/posts/2011/aug/22/contact-form-in-rails-3 | |
# http://railscasts.com/episodes/206-action-mailer-in-rails-3 | |
# config/initializers/smtp_settings.rb | |
ActionMailer::Base.smtp_settings = { | |
:address => "smtp.gmail.com", | |
:port => 587, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
respond_to do |format| | |
format.html # show.html.erb | |
format.json { render :json => @model } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# return copyright declaration with current year | |
def copyright | |
copyright = '© '.html_safe + Time.new.strftime('%Y') + ' [Company]. All Rights Reserved' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# return a title on a per-page basis | |
def title | |
base_title = "[Site Name]" | |
if @title.nil? | |
base_title | |
else | |
"#{base_title} | #{@title}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# return body class for markup | |
def body_class | |
base_body_class = "[site-name]" | |
if @body_class.nil? | |
base_body_class | |
else | |
base_body_class + " #{@body_class}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# concatenate a user model's first and last name, include middle name or suffix if required | |
# may consider abbreviating the middle name | |
def fullname | |
if middlename.nil? then | |
fullname = firstname + ' ' + lastname | |
else | |
fullname = firstname + ' ' + middlename + ' ' + lastname | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#simple cli for updating ubuntu | |
$ apt-get update && apt-get upgrade |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
Model.delete_all #if refreshing | |
doc = Nokogiri::XML(File.read("app/assets/files/example.xml")) | |
@doc = doc.xpath('//node_name').each do |record| | |
Model.create( | |
:column1 => record.at('@element_id').text, | |
:column2 => record.at('node_name').text, |
OlderNewer