Class: ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Includes:
InheritedResources::DSL
Defined in:
app/controllers/application_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.resource_attributes(*parameters) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/application_controller.rb', line 14

def self.resource_attributes(*parameters)
  for action in [:show, :new, :edit, :create]
    a = "def #{action};" + ([:new, :create].include?(action) ?
      "@#{resource_class.name.underscore} = resource_class.new;" : ""
    ) +
    parameters.map{|p|
        if p.class == Hash
          meth, prm = [p.to_a.flatten[0], p.to_a.flatten[1]]
        else
          meth, prm = [p, p]
        end
        meth = meth.to_s + "="

        if prm == :current_user
          val = "current_user"
        else
          val = "params[:#{prm}]"
        end
        "resource.send(\"#{meth}\", #{val})"
      }.join(";") +
      ";#{action}!;end;"
    class_eval a
    puts a
  end
end

Instance Method Details

#include_jqueryuiObject



4
5
6
7
8
9
# File 'app/controllers/application_controller.rb', line 4

def include_jqueryui
  content_for :head do
    stylesheet_link_tag("ui-lightness/jquery-ui-1.8.4.custom")
    javascript_include_tag("jquery-ui")
  end
end