how_are_we_doing 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,11 @@
1
1
  class PrintsController < ApplicationController
2
2
  respond_to :html, :json, :xml, :js
3
+ before_filter :add_user
3
4
 
4
5
  def create
5
- @print = parent.prints.create
6
+ @print = parent.prints.create(params[:print]||{})
6
7
 
7
- respond_with @print
8
+ respond_with(@print, :location => send("#{parent.class.name.underscore}_url",parent))
8
9
  end
9
10
 
10
11
  protected
@@ -13,4 +14,11 @@ class PrintsController < ApplicationController
13
14
  instance_variable_set("@#{params[:printable_type].underscore}",@parent)
14
15
  end
15
16
 
17
+ def add_user
18
+ if defined?(current_user) && current_user
19
+ params[:print] ||= {}
20
+ params[:print][:user_id] = current_user.id
21
+ end
22
+ end
23
+
16
24
  end
@@ -1,10 +1,11 @@
1
1
  class SharesController < ApplicationController
2
2
  respond_to :html, :json, :xml, :js
3
+ before_filter :add_user
3
4
 
4
5
  def create
5
- @share = parent.shares.create
6
+ @share = parent.shares.create((params[:share]||{}))
6
7
 
7
- respond_with @share
8
+ respond_with(@share, :location => send("#{parent.class.name.underscore}_url",parent))
8
9
  end
9
10
 
10
11
  protected
@@ -13,4 +14,11 @@ class SharesController < ApplicationController
13
14
  instance_variable_set("@#{params[:shareable_type].underscore}",@parent)
14
15
  end
15
16
 
17
+ def add_user
18
+ if defined?(current_user) && current_user
19
+ params[:share] ||= {}
20
+ params[:share][:user_id] = current_user.id
21
+ end
22
+ end
23
+
16
24
  end
@@ -1,10 +1,11 @@
1
1
  class ViewsController < ApplicationController
2
2
  respond_to :html, :json, :xml, :js
3
+ before_filter :add_user
3
4
 
4
5
  def create
5
- @view = parent.views.create
6
+ @view = parent.views.create((params[:view]||{}))
6
7
 
7
- respond_with @view
8
+ respond_with(@view, :location => send("#{parent.class.name.underscore}_url",parent))
8
9
  end
9
10
 
10
11
  protected
@@ -13,4 +14,11 @@ class ViewsController < ApplicationController
13
14
  instance_variable_set("@#{params[:viewable_type].underscore}",@parent)
14
15
  end
15
16
 
17
+ def add_user
18
+ if defined?(current_user) && current_user
19
+ params[:view] ||= {}
20
+ params[:view][:user_id] = current_user.id
21
+ end
22
+ end
23
+
16
24
  end
data/app/models/share.rb CHANGED
@@ -1,3 +1,8 @@
1
1
  class Share < ActiveRecord::Base
2
2
  belongs_to :shareable, :polymorphic => true
3
+ before_create :set_url_hash
4
+
5
+ def set_url_hash
6
+ self.url_hash = Digest::SHA1.hexdigest("#{shareable_type}#{shareable_id}#{user_id}how_are_we_doing#{service_ident}"
7
+ end
3
8
  end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ This will set up a Gunner Technology Rails Project
3
+
4
+ Example:
5
+ rails generate project Thing
6
+
7
+ This will create:
8
+ a/lot/of/stuff
@@ -7,7 +7,7 @@ module HowAreWeDoing
7
7
 
8
8
  def self.next_migration_number(dirname)
9
9
  if ActiveRecord::Base.timestamped_migrations
10
- Time.now.utc.strftime("%Y%m%d%H%M%S")
10
+ Time.now.utc.strftime("%Y%m%d%H%M%S%L")
11
11
  else
12
12
  "%.3d" % (current_migration_number(dirname) + 1)
13
13
  end
@@ -10,7 +10,7 @@ class CreateShares < ActiveRecord::Migration
10
10
 
11
11
  add_index :shares, [:shareable_id, :shareable_type]
12
12
  add_index :shares, :user_id
13
- add_index :shares, :server_ident
13
+ add_index :shares, :service_ident
14
14
  add_index :shares, :url_hash
15
15
  end
16
16
 
@@ -1,3 +1,3 @@
1
1
  module HowAreWeDoing
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Gunner Technology, Cody Swann
@@ -41,10 +41,11 @@ files:
41
41
  - lib/acts_as_printable.rb
42
42
  - lib/acts_as_shareable.rb
43
43
  - lib/acts_as_viewable.rb
44
- - lib/generators/install_generator.rb
45
- - lib/generators/templates/db/migrate/create_prints.rb
46
- - lib/generators/templates/db/migrate/create_shares.rb
47
- - lib/generators/templates/db/migrate/create_views.rb
44
+ - lib/generators/how_are_we_doing/USAGE
45
+ - lib/generators/how_are_we_doing/install/install_generator.rb
46
+ - lib/generators/how_are_we_doing/install/templates/db/migrate/create_prints.rb
47
+ - lib/generators/how_are_we_doing/install/templates/db/migrate/create_shares.rb
48
+ - lib/generators/how_are_we_doing/install/templates/db/migrate/create_views.rb
48
49
  - lib/how_are_we_doing.rb
49
50
  - lib/how_are_we_doing/version.rb
50
51
  has_rdoc: true