class Kablam::Generators::InstallGenerator

Public Instance Methods

basic_setup() click to toggle source

argument :name, :type => :string, :default => “en”

# File lib/generators/kablam/install_generator.rb, line 9
def basic_setup
  # Change ApplicationRecord's inheritence
  gsub_file 'app/models/application_record.rb', 'class ApplicationRecord < ActiveRecord::Base', 'class ApplicationRecord < Kablam::KablamRecord'

  # Setup Initializer
  template "kablam.rb", "config/initializers/kablam.rb"
  copy_file "_sample_target_item.html.erb", "app/views/kablam/models/_sample_target_item.html.erb"
end
setup_assets() click to toggle source
# File lib/generators/kablam/install_generator.rb, line 24
def setup_assets
  inject_into_file 'app/assets/javascripts/application.js', before: "//= require_tree ." do
    "//= require kablam/ajax \n//= require kablam/forms\n"
  end
  prepend_file 'app/assets/stylesheets/application.css.scss', "@import 'kablam';\n"
end
setup_routes() click to toggle source
# File lib/generators/kablam/install_generator.rb, line 17
def setup_routes
  inject_into_file 'config/routes.rb', before: "end" do
    "  # KABLAM! form/create/update/destroy/undo for all models\n  # Note: Make sure Kablam engine is at the BOTTOM of routes\n  # helpers to use KABLAM! [examples w/ 'posts' model)\n  # --->  kablam.form_path('posts')\n  #  (if edit form, must add '?id=\#\{@post.id\}' to path)\n  # --->  kablam.create_path('posts')\n  # --->  kablam.delete_path('posts', @post)\n  # --->  kablam.update_path('posts', @post)\n  # --->  kablam.undo_path('posts', @post)\n  mount Kablam::Engine => '/kablam', as: 'kablam'\n"
  end

end