Top Level Namespace

Defined Under Namespace

Modules: Breezy, Rails

Instance Method Summary collapse

Instance Method Details

#add_member_methodsObject

TODO: add member_key



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/install/web.rb', line 24

def add_member_methods
  inject_into_file "app/models/application_record.rb", after: "class ApplicationRecord < ActiveRecord::Base\n" do
    <<-RUBY
  def self.member_at(index)
    offset(index).limit(1).first
  end

  def self.member_by(attr, value)
    find_by(Hash[attr, value])
  end

  def self.member_key
    "id"
  end

    RUBY
  end
end

#append_js_tagsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/install/web.rb', line 5

def append_js_tags
  app_html = 'app/views/layouts/application.html.erb'
  js_tag = <<-JS_TAG

    <script type="text/javascript">
      window.BREEZY_INITIAL_PAGE_STATE=<%= @initial_state.html_safe %>;
    </script>
  JS_TAG

  inject_into_file app_html, after: '<head>' do
    js_tag
  end

  inject_into_file app_html, after: '<body>' do
    "\n    <div id='app'></div>"
  end
end