Class: Storytime::Site
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Storytime::Site
- Defined in:
- app/models/storytime/site.rb
Class Method Summary collapse
Instance Method Summary collapse
- #active_email_subscriptions ⇒ Object
- #custom_view_path ⇒ Object
- #root_post_options ⇒ Object
- #save_with_seeds(user) ⇒ Object
Class Method Details
.current ⇒ Object
32 33 34 |
# File 'app/models/storytime/site.rb', line 32 def self.current find(current_id) if current_id end |
.current_id ⇒ Object
28 29 30 |
# File 'app/models/storytime/site.rb', line 28 def self.current_id Thread.current[:storytime_site_id] end |
.current_id=(id) ⇒ Object
24 25 26 |
# File 'app/models/storytime/site.rb', line 24 def self.current_id=(id) Thread.current[:storytime_site_id] = id end |
Instance Method Details
#active_email_subscriptions ⇒ Object
58 59 60 |
# File 'app/models/storytime/site.rb', line 58 def active_email_subscriptions subscriptions.active end |
#custom_view_path ⇒ Object
62 63 64 |
# File 'app/models/storytime/site.rb', line 62 def custom_view_path self.title.parameterize end |
#root_post_options ⇒ Object
54 55 56 |
# File 'app/models/storytime/site.rb', line 54 def Storytime::Post.published.where(type: ["Storytime::Page", "Storytime::Blog"]) end |
#save_with_seeds(user) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/models/storytime/site.rb', line 36 def save_with_seeds(user) self.creator = user if save self.class.setup_seeds Storytime::Membership.create(user: user, site: self, storytime_role: Storytime::Role.find_by(name: "admin")) blog = Storytime::Blog.seed(self, user) self.update_column("root_post_id", blog.id) else false end end |