lib/generators/buildybuild/cms/cms_generator.rb in buildybuild-0.0.1 vs lib/generators/buildybuild/cms/cms_generator.rb in buildybuild-1.0.0

- old
+ new

@@ -24,11 +24,11 @@ template("cms_show_view.html.haml", "app/views/#{file_names}/show.html.haml") template("cms_form_partial.html.haml", "app/views/#{file_names}/_form.html.haml") end def add_routes - insert_into_file "config/routes.rb", generated_routes, before: /^end\s*$/ + insert_into_file "config/routes.rb", generated_routes, before: /end\n*$/ end private def generated_routes @@ -37,13 +37,14 @@ #keep these at the bottom of your file. They should be the last routes. get "/:slug", to: "pages#show", as: :slug get "/:slug/edit", to: "pages#edit", as: :edit_slug put "/:slug", to: "pages#update", as: :slug - post "/:slug", to: "pages#destroy", as: :slug\n\n) + post "/:slug", to: "pages#destroy", as: :slug\n) end + def file_name model_name.underscore end def file_names @@ -54,9 +55,13 @@ file_name.camelize end def klasses file_name.pluralize.camelize + end + + def table_name + klasses.downcase end def controller_name "#{file_name.pluralize}Controller".camelize end