Class: Jimothy::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Jimothy::Generators::InstallGenerator
- Defined in:
- lib/generators/jimothy/install_generator.rb
Instance Method Summary collapse
- #add_image_tag ⇒ Object
- #add_jimothy_call ⇒ Object
- #empty_seed_file ⇒ Object
- #scaffold_users ⇒ Object
- #seed_users ⇒ Object
Instance Method Details
#add_image_tag ⇒ Object
11 12 13 |
# File 'lib/generators/jimothy/install_generator.rb', line 11 def add_image_tag gsub_file 'app/views/users/_user.html.erb',/<%= user.image %>/,'<%= image_tag user.image %>' end |
#add_jimothy_call ⇒ Object
17 18 19 |
# File 'lib/generators/jimothy/install_generator.rb', line 17 def add_jimothy_call gsub_file 'db/seeds.rb',/./,"require \"jimothy\"\nJimothy::seed_users" end |
#empty_seed_file ⇒ Object
14 15 16 |
# File 'lib/generators/jimothy/install_generator.rb', line 14 def empty_seed_file gsub_file 'db/seeds.rb',/# This file should contain all the record creation needed to seed the database with its default values.\n# The data can then be loaded with the bin\/rails db:seed command \(or created alongside the database with db:setup\).\n#\n# Examples:\n#\n# movies = Movie.create\(\[\{ name: \"Star Wars\" \}, \{ name: \"Lord of the Rings\" \}\]\)\n# Character.create\(name: \"Luke\", movie: movies.first\)\n/,'.' end |
#scaffold_users ⇒ Object
7 8 9 10 |
# File 'lib/generators/jimothy/install_generator.rb', line 7 def scaffold_users %x(rails g scaffold user name email image) %x(rails db:migrate) end |
#seed_users ⇒ Object
20 21 22 |
# File 'lib/generators/jimothy/install_generator.rb', line 20 def seed_users %x(rails db:seed) end |