aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKir2011-11-01 11:15:43 +0400
committerKir2011-11-01 11:15:43 +0400
commit54078bc80f3c05a7f2b2b6cb31e2496adb3fe0b1 (patch)
tree8e4ab0d91ea59c1d9b3e347f2f48f1b4ebd2aa23
parent48c144ed34e2d5977bb8e5af8a9c7e8dfc253361 (diff)
downloadinboxes-54078bc80f3c05a7f2b2b6cb31e2496adb3fe0b1.tar.bz2
Installation guide in readme and active record extension
-rw-r--r--README.md18
-rw-r--r--app/controllers/discussions_controller.rb3
-rw-r--r--lib/generators/inboxes/views_generator.rb7
-rw-r--r--lib/inboxes.rb5
-rw-r--r--lib/inboxes/active_record_extension.rb13
5 files changed, 38 insertions, 8 deletions
diff --git a/README.md b/README.md
index e7b4fbd..9ecb749 100644
--- a/README.md
+++ b/README.md
@@ -10,4 +10,20 @@ Inboxes is a young messaging system for Rails app. It:
Inboxes requires Rails 3.x and [Devise](https://github.com/plataformatec/devise) for user identification (surely, messaging system is not possible without users).
-We recommend you to use it with [Faye](https://github.com/jcoglan/faye), because it's really very useful with it. \ No newline at end of file
+We recommend to use Inboxes with [Faye](https://github.com/jcoglan/faye), because it's really useful with it.
+
+Remember that unfortunately, Inboxes reserve 3 model names: Discussion, DiscussionView, Message and Speaker and 2 controller names: Messages and Discussions.
+
+#Installation
+
+0. Make sure that Devise is already installed and configured.
+
+1. Add `gem "inboxes", :git => git://github.com/kirs/inboxes.git` to your `Gemfile` and run `bundle install`
+2. Run `rails generate inboxes:install`. This command will generate migration for messaging system. Then run `rake db:migrate`
+3. Add `inboxes` to your User model like [here](https://gist.github.com/1330080)
+4.
+
+##Todo
+
+- add rspec tests
+- move controllers and models to namespace \ No newline at end of file
diff --git a/app/controllers/discussions_controller.rb b/app/controllers/discussions_controller.rb
index 8ea6459..eb91cfc 100644
--- a/app/controllers/discussions_controller.rb
+++ b/app/controllers/discussions_controller.rb
@@ -1,6 +1,6 @@
class DiscussionsController < ApplicationController
before_filter :authenticate_user!
- before_filter :check_permissions, :only => :show
+ # before_filter :check_permissions, :only => :show
before_filter :load_and_check_discussion_recipient, :only => [:create, :new]
@@ -74,7 +74,6 @@ class DiscussionsController < ApplicationController
redirect_to discussion_url(discussion), :notice => t("views.discussions.exists", :user => user[Inboxes::config.user_name])
end
end
-
end
end
diff --git a/lib/generators/inboxes/views_generator.rb b/lib/generators/inboxes/views_generator.rb
index c69812e..07200ae 100644
--- a/lib/generators/inboxes/views_generator.rb
+++ b/lib/generators/inboxes/views_generator.rb
@@ -7,11 +7,10 @@ module Inboxes
class_option :template_engine, :type => :string, :aliases => '-e', :desc => 'Template engine for the views. Available options are "erb" and "haml".'
def copy_or_fetch
- # puts "Generating views"
- filename_pattern = File.join self.class.source_root, "*/*.html.#{template_engine}"
- # puts (Dir.glob(filename_pattern).map {|f| File.basename f}).inspect
+ # filename_pattern = File.join self.class.source_root, "discussions", "*.html.#{template_engine}"
+ # puts Dir.glob(filename_pattern).map {|f| File.basename f}.inspect
# Dir.glob(filename_pattern).map {|f| File.basename f}.each do |f|
- # copy_file f, "app/views/#{f}"
+ # # copy_file f, "app/views/#{f}"
# end
end
diff --git a/lib/inboxes.rb b/lib/inboxes.rb
index 9759f07..49bec39 100644
--- a/lib/inboxes.rb
+++ b/lib/inboxes.rb
@@ -1,9 +1,9 @@
require "inboxes/version"
require "inboxes/railtie"
require "inboxes/engine"
+require "inboxes/active_record_extension"
module Inboxes
- # Your code goes here...
def self.configure(&block)
yield @config ||= Inboxes::Configuration.new
@@ -24,4 +24,7 @@ module Inboxes
end
end
+ # adding method inboxes for models
+ ActiveRecord::Base.extend(Inboxes::ActiveRecordExtension)
+
end
diff --git a/lib/inboxes/active_record_extension.rb b/lib/inboxes/active_record_extension.rb
new file mode 100644
index 0000000..1cb94f2
--- /dev/null
+++ b/lib/inboxes/active_record_extension.rb
@@ -0,0 +1,13 @@
+module Inboxes
+ module ActiveRecordExtension
+ def inboxes(options = {})
+ # field = options[:as] || name
+ # prefix = options[:prefix] || "with"
+
+ has_many :speakers, :dependent => :destroy
+ has_many :discussions, :through => :speakers
+
+ # scope "#{prefix}_#{name}", lambda {|value| where("#{field}" => value) }
+ end
+ end
+end \ No newline at end of file