Class: ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
lib/ecrire/app/controllers/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#current_userObject



8
9
10
# File 'lib/ecrire/app/controllers/application_controller.rb', line 8

def current_user
  warden.user
end

#post_path(post, options = {}) ⇒ Object

This is the less ugly hack I could find. The reason why this is here is because helpers are hard to debug due to their anonymous Module use.



18
19
20
21
22
23
24
25
26
27
# File 'lib/ecrire/app/controllers/application_controller.rb', line 18

def post_path(post, options = {})
  options[:controller] = :posts
  options[:action] = :show
  options[:year] = post.published_at.year
  options[:month] = post.published_at.month

  options[:id] = (options.delete(:title) || post.titles.first).slug

  theme.url_for options
end

#signed_in?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/ecrire/app/controllers/application_controller.rb', line 12

def signed_in?
  !warden.user.nil?
end