Skip to content

Instantly share code, notes, and snippets.

View hmans's full-sized avatar
🚀
Let's go!

Hendrik Mans hmans

🚀
Let's go!
View GitHub Profile
foo?
...---...
../ / | \ \..
./ / / | \ \ \.
/ / / | \ \ \
/ / / | \ \ \
^^^^^^^^^^^^^^^^^^^^^^^
\ | /
\ | /
\ | /
\ | /
.:IIIIHIHHIHHHII::I:.
.IIIIHIHHHHHHIHIIIIMHHI:,
:IIIIHIHHHHHHMMHHIHHIIHHIII:.
.:IHIHHHHHHHHHHHHHIHIHHIHHHIH:I:,
,.:HIHHHHHHHHHHHHHHHHHHHHHIHIHHII:.
,.:IHHHHHHHHHHMMMMHHHHHHHIIHHHIHIII,
def current_user_session
return @current_user_session if defined?(@current_user_session)
@current_user_session = UserSession.find
end
kürzer:
def current_user_session
@current_user_session ||= UserSession.find
end
class User < ActiveRecord::Base
validates_uniqueness_of :email, :case_sensitive => false
validate :valid_email?
private
def valid_email?
address = EmailVeracity::Address.new(email)
def set_page_title(title = nil, &block)
if block_given?
html = capture(&block)
concat(html)
end
@page_title = title || strip_tags(html)
end
# place this in application_helper.rb
def set_page_title(title = nil, &block)
if block_given?
html = capture(&block)
concat(html)
end
@page_title = title || strip_tags(html)
end
- set_page_title do
%h1
%strong Ein neuer User.
Wie spannend!
- set_page_title "Neuer User"
Add localized templates
# Default locale
app/views/messages/index.html.erb
# I18n.locale is set to :da (Danish)
app/views/messages/index.da.html.erb