Class: Forem::TopicsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Forem::TopicsController
- Defined in:
- app/controllers/forem/topics_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/forem/topics_controller.rb', line 13 def create rawtopic = params[:topic][:subject] @topic = Forem::Topic.create({user_id: current_user.id, subject: rawtopic}) rawposts = params[:topic][:posts_attributes] rawposts.each do |raw| @topic.posts.create(text: raw[1][:text]) end @topic.save! flash[:notice] = "Topic has been created!" redirect_to @topic end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/forem/topics_controller.rb', line 5 def index @topics = Forem::Topic.all end |