Class: TextsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- TextsController
- Defined in:
- app/controllers/texts_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/texts_controller.rb', line 17 def create @text = @owner.texts.build(params[:text]) if @owner.save flash[:notice] = "Successfully created text." redirect_to :back else render :action => 'new' end end |
#destroy ⇒ Object
42 43 44 45 46 47 |
# File 'app/controllers/texts_controller.rb', line 42 def destroy @text = Text.find(params[:id]) @text.destroy flash[:notice] = "Successfully destroyed text." redirect_to :back end |
#edit ⇒ Object
27 28 29 30 |
# File 'app/controllers/texts_controller.rb', line 27 def edit @text = Text.find(params[:id]) render :layout => false end |
#index ⇒ Object
3 4 5 |
# File 'app/controllers/texts_controller.rb', line 3 def index @texts = Text.all end |
#new ⇒ Object
11 12 13 14 15 |
# File 'app/controllers/texts_controller.rb', line 11 def new @index = Index.find(params[:index_id]) @text = @index.texts.build(:priority => ((@index.texts.first.lowest_priority + 1) rescue 0)) render :layout => false end |
#show ⇒ Object
7 8 9 |
# File 'app/controllers/texts_controller.rb', line 7 def show @text = Text.find(params[:id]) end |
#update ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/texts_controller.rb', line 32 def update @text = Text.find(params[:id]) if @text.update_attributes(params[:text]) flash[:notice] = "Successfully updated text." redirect_to :back else render :action => 'edit' end end |