Method: Espresso::View::InstanceMethods#link_to_new

Defined in:
lib/espresso/view/inherited_resources.rb


7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/espresso/view/inherited_resources.rb', line 7

def link_to_new(klass=nil, path=nil)
  klass ||= resource_class
  klass_underscored = klass.name.underscore
  path ||= if klass == resource_class
             new_resource_path
           else
             [:new, klass_underscored]
           end
  link_to(t("helpers.action.#{klass_underscored}.new",
            :default => [:'helpers.action.new', 'Add']),
          path,
          :class => Espresso::View.block_classes('action', %w(new)))
rescue
end