Class: Formol::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/formol/generators/install/install_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_user_helperObject

Returns the value of attribute current_user_helper.



6
7
8
# File 'lib/formol/generators/install/install_generator.rb', line 6

def current_user_helper
  @current_user_helper
end

#user_classObject

Returns the value of attribute user_class.



6
7
8
# File 'lib/formol/generators/install/install_generator.rb', line 6

def user_class
  @user_class
end

Instance Method Details

#copy_formol_config_ymlObject



37
38
39
# File 'lib/formol/generators/install/install_generator.rb', line 37

def copy_formol_config_yml
  template 'config/formol.yml', "#{Rails.root}/config/formol.yml"
end

#copy_special_rightsObject



41
42
43
# File 'lib/formol/generators/install/install_generator.rb', line 41

def copy_special_rights
  template 'lib/permissions/special_rights.rb', "#{Rails.root}/lib/formol/permissions/special_rights.rb"
end

#finishedObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/formol/generators/install/install_generator.rb', line 49

def finished
  puts <<END
#{'=' * 90}
Formol is now installed into your application
You can access it with http://yourhost/forums

* Formol migrations were copied into db/migrate and there was also two migrations for #{user_class} created.
* A new initializer called formol has been added to 'config/initializers'
* A yaml file wich contains profiles and permissions has been added to 'config'
* A module to define special rights has been added to 'lib/formol/permissions/special_rights'
* The formol engine was mounted in 'config/routes.rb'

What you need to do if you wanna formol work:

* run 'rake db:migrate'
* add '<%= include_formol_javascripts %>' and '<%= include_formol_stylesheets %>' in the head section of your application layout
* add 'include Formol::Integration::User' in your #{user_class} model

If you want to change where the forums are located, just change the "forums" path in 'config/routes.rb'.

By default, Formol will use markdown as text formatting language. You can change it in 'config/initializer/formol.rb' (other option is :bbcode)

Formol is delivered with no warranty under MIT license.
However, if you have any question, suggestion or issue, you can post them on our github repository, at the following address: https://github.com/mulasse/formol/issues

Thank your for using Formol.
#{'=' * 90}

END
end

#get_current_user_helperObject



19
20
21
22
# File 'lib/formol/generators/install/install_generator.rb', line 19

def get_current_user_helper
  self.current_user_helper = ask("What is the 'current_user' helper called in your main app? [current_user]")
  self.current_user_helper = 'current_user' if current_user_helper.blank?
end

#get_user_classObject



12
13
14
15
16
17
# File 'lib/formol/generators/install/install_generator.rb', line 12

def get_user_class
  self.user_class = ask("What is you user model called? [User]")
  self.user_class = 'user' if user_class.blank?
  
  self.user_class = user_class.classify
end

#install_formol_initializerObject



33
34
35
# File 'lib/formol/generators/install/install_generator.rb', line 33

def install_formol_initializer
  template 'initializer/formol.rb.erb', "#{Rails.root}/config/initializers/formol.rb"
end

#install_formol_user_migrationsObject



28
29
30
31
# File 'lib/formol/generators/install/install_generator.rb', line 28

def install_formol_user_migrations
  template 'migrations/add_formol_profile_to_users.rb.erb', "#{Rails.root}/db/migrate/#{next_migration_number}_add_formol_profile_to_user.rb"
  template 'migrations/add_posts_count_to_user.rb.erb',     "#{Rails.root}/db/migrate/#{next_migration_number}_add_posts_count_to_user.rb"
end

#install_migrationsObject



24
25
26
# File 'lib/formol/generators/install/install_generator.rb', line 24

def install_migrations
  rake 'formol:install:migrations'
end

#mount_engineObject



45
46
47
# File 'lib/formol/generators/install/install_generator.rb', line 45

def mount_engine
  inject_into_file("#{Rails.root}/config/routes.rb", %{  mount Formol::Engine => "/forums", :as => :formol\n}, :after => /routes.draw.do\n/)
end