Class: Phcpresspro::Articles::PostsController

Inherits:
Phcpresspro::ApplicationController show all
Defined in:
app/controllers/phcpresspro/articles/posts_controller.rb

Instance Method Summary collapse

Methods inherited from Phcpresspro::ApplicationController

#current_user, #membership_info, #new_login_url, #phcpress_recent_posts, #require_user

Instance Method Details

#createObject

POST



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/phcpresspro/articles/posts_controller.rb', line 30

def create
  @articles_post = Articles::Post.new(articles_post_params)
  @articles_post.user_id = current_user.id
  @articles_post.user_name = current_user.username
  @articles_post.membership_id = membership_info.id
  @articles_post.oganization_id = membership_info.org_id
  if @articles_post.save
    @articles_post.connections.build
    redirect_to articles_posts_url, notice: 'Post was successfully created.'
    else
      render :new
  end
end

#destroyObject

DELETE



59
60
61
62
# File 'app/controllers/phcpresspro/articles/posts_controller.rb', line 59

def destroy
@articles_post.destroy
  redirect_to articles_posts_url, notice: 'Post was successfully destroyed.'
end

#editObject

Article Edit



26
27
# File 'app/controllers/phcpresspro/articles/posts_controller.rb', line 26

def edit
end

#indexObject

Article Index



12
13
14
# File 'app/controllers/phcpresspro/articles/posts_controller.rb', line 12

def index
  @articles_posts = Articles::Post.all
end

#newObject

Article New



21
22
23
# File 'app/controllers/phcpresspro/articles/posts_controller.rb', line 21

def new
  @articles_post = Articles::Post.new
end

#showObject

Article Show



17
18
# File 'app/controllers/phcpresspro/articles/posts_controller.rb', line 17

def show
end

#updateObject

PATCH/PUT



45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/phcpresspro/articles/posts_controller.rb', line 45

def update
  @articles_post.user_id = current_user.id
  @articles_post.user_name = current_user.username
  @articles_post.membership_id = membership_info.id
  @articles_post.oganization_id = membership_info.org_id
  if @articles_post.update(articles_post_params)
    @articles_post.connections.build
    redirect_to articles_posts_url, notice: 'Post was successfully updated.'
    else
      render :edit
  end
end