Sha256: 99bd0922b33c3bc2fafbcf4438b9153dc57f7f6bc21fe2dbd456cddbac34eb61

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

#!/usr/bin/env ruby

require 'fileutils'
extend FileUtils

system 'bin/rails g scaffold Post title body'
system 'bin/rails db:migrate'

mkdir_p 'sandbox/app/overrides'

File.write 'sandbox/app/overrides/improved_posts.rb', <<~RUBY
  Deface::Override.new(
    virtual_path: "posts/show",
    name: "sparkling_post_title",
    replace: 'p:nth-child(2)',
    text: "<h1>✨<%= @post.title %>✨</h1>"
  )

  Deface::Override.new(
    virtual_path: "posts/show",
    name: "modern_style_post_body",
    replace: 'p:nth-child(3)',
    text: "<p style='border:2px gray solid; padding: 1rem;'><%= @post.body %></p>"
  )

  Deface::Override.new(
    virtual_path: "posts/index",
    name: "sparkling_posts_title",
    replace: 'tr td:first-child',
    text: "<td>✨<%= post.title %>✨</td>"
  )

  Deface::Override.new(
    virtual_path: "posts/index",
    name: "modern_style_post_body",
    replace: 'tr td:nth-child(2)',
    text: "<td style='border:2px gray solid; padding: 1rem;'><%= post.body %></d>"
  )
RUBY

File.write 'sandbox/config/routes.rb', <<~RUBY
  Rails.application.routes.draw do
    resources :posts
    root to: "posts#index"
  end
RUBY

system "bin/rails", "runner", "Post.create(title: 'Foo', body: 'Bar '*10)"
system "bin/rails", "runner", "Post.create(title: 'Baz', body: 'Boz '*10)"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deface-1.7.0 bin/sandbox-setup