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, #require_user

Instance Method Details

#createObject

POST



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

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



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

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

#editObject

Article Edit



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

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
24
# 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



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

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