Class: Lesli::Generators::ViewsGenerator
- Inherits:
-
BaseGenerator
- Object
- Rails::Generators::NamedBase
- BaseGenerator
- Lesli::Generators::ViewsGenerator
- Defined in:
- lib/generators/lesli/views/views_generator.rb
Overview
Generates Lesli-style views for a resource inside the current engine.
Example:
rails generate lesli:views tickets subject:string description:text owner_id:integer
Result:
app/views/lesli_support/tickets/
_form.html.erb
index.html.erb
show.html.erb
new.html.erb
edit.html.erb
Instance Method Summary collapse
-
#create_form_partial ⇒ Object
Generates the shared form partial.
-
#create_index_view ⇒ Object
Generates the index view.
-
#create_new_view ⇒ Object
Generates the new view.
-
#create_show_view ⇒ Object
Generates the show view.
-
#create_views_directory ⇒ Object
Creates the views directory if it does not exist.
Instance Method Details
#create_form_partial ⇒ Object
Generates the shared form partial.
31 32 33 |
# File 'lib/generators/lesli/views/views_generator.rb', line 31 def create_form_partial template "_form.html.erb.tt", File.join(views_directory, "_form.html.erb") end |
#create_index_view ⇒ Object
Generates the index view.
36 37 38 |
# File 'lib/generators/lesli/views/views_generator.rb', line 36 def create_index_view template "index.html.erb.tt", File.join(views_directory, "index.html.erb") end |
#create_new_view ⇒ Object
Generates the new view.
46 47 48 |
# File 'lib/generators/lesli/views/views_generator.rb', line 46 def create_new_view template "new.html.erb.tt", File.join(views_directory, "new.html.erb") end |
#create_show_view ⇒ Object
Generates the show view.
41 42 43 |
# File 'lib/generators/lesli/views/views_generator.rb', line 41 def create_show_view template "show.html.erb.tt", File.join(views_directory, "show.html.erb") end |
#create_views_directory ⇒ Object
Creates the views directory if it does not exist.
26 27 28 |
# File 'lib/generators/lesli/views/views_generator.rb', line 26 def create_views_directory empty_directory views_directory end |