Class: Fetty::Generators::MessagesGenerator

Inherits:
Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/fetty/messages/messages_generator.rb

Instance Method Summary collapse

Methods inherited from Base

banner, source_root

Instance Method Details

#generate_messagesObject

have to inject this tag on application.html.erb layout <%= link_to “inbox(#=> false).count)”, messages_path(:inbox), :id => “inbox-link” %> |



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/generators/fetty/messages/messages_generator.rb', line 16

def generate_messages
  if options.destroy?
    destroy_messages
  else
    @model_path = "app/models/user.rb"
    if file_exists?(@model_path)
      unless using_mongoid?
        @orm = using_mongoid? ? 'mongoid' : 'active_record'
        gem "ancestry"
        copy_models_and_migrations
        copy_controller_and_helper
        copy_views
        copy_assets
        must_load_lib_directory
        add_routes
        insert_links_on_layout
        generate_specs if using_rspec?
      else
        raise "Sorry, fetty:messages only works with ActiveRecord !!"
      end
    else
      raise "You don't have User model, please install some authentication first!"
    end
  end
rescue Exception => e
  print_notes(e.message,"error",:red)
end