Class: Thredded::EditTopicForm
- Inherits:
-
Object
- Object
- Thredded::EditTopicForm
- Includes:
- ActiveModel::Model
- Defined in:
- app/forms/thredded/edit_topic_form.rb
Class Method Summary collapse
Instance Method Summary collapse
- #category_options ⇒ Object
- #edit_path ⇒ Object
-
#initialize(user:, topic:) ⇒ EditTopicForm
constructor
A new instance of EditTopicForm.
- #messageboard_options ⇒ Object
- #messageboard_path ⇒ Object
- #path ⇒ Object
- #persisted? ⇒ Boolean
- #save ⇒ Object
Constructor Details
#initialize(user:, topic:) ⇒ EditTopicForm
Returns a new instance of EditTopicForm.
12 13 14 15 |
# File 'app/forms/thredded/edit_topic_form.rb', line 12 def initialize(user:, topic:) @user = user @topic = topic end |
Class Method Details
Instance Method Details
#category_options ⇒ Object
21 22 23 |
# File 'app/forms/thredded/edit_topic_form.rb', line 21 def @topic..categories.map { |cat| [cat.name, cat.id] } end |
#edit_path ⇒ Object
43 44 45 |
# File 'app/forms/thredded/edit_topic_form.rb', line 43 def edit_path Thredded::UrlsHelper.(@topic., @topic) end |
#messageboard_options ⇒ Object
25 26 27 |
# File 'app/forms/thredded/edit_topic_form.rb', line 25 def @user..map { || [.name, .id] } end |
#messageboard_path ⇒ Object
47 48 49 |
# File 'app/forms/thredded/edit_topic_form.rb', line 47 def Thredded::UrlsHelper.(@topic.) end |
#path ⇒ Object
39 40 41 |
# File 'app/forms/thredded/edit_topic_form.rb', line 39 def path Thredded::UrlsHelper.(@topic., @topic) end |
#persisted? ⇒ Boolean
35 36 37 |
# File 'app/forms/thredded/edit_topic_form.rb', line 35 def persisted? true end |
#save ⇒ Object
29 30 31 32 33 |
# File 'app/forms/thredded/edit_topic_form.rb', line 29 def save return false unless valid? @topic.save! true end |